如何将自定义标头传递给c#中的终点 [英] how to pass the custom Header to End point in c#
问题描述
在我的项目中,我正在使用.net端的java服务。所以我必须通过标题。使用App.Config我能够传递标题。但我必须删除App.config文件,没有App.config文件我必须使用c#传递标题。
例如:
< bindings>
< basichttpbinding>
<绑定名称=NewBindng>
< security mode =Transport>
< client>
< endpoint address =http:// localhost:8162 / Emp / Index>
binding =basicHttpBinding bindingConfiguration =Newbinding
contract =MyProject.Servicename =SearchGlobalAssociateV2>
< headers>
< wsse:security xmlns:wsse =#unknown>
< wsse:usernametoken>
< wsse:username> satheesh
< wsse:password> kumar
< ns1:subscriptionenforcement>
< ns1:subscriberid xmlns:ns1 =#unknown>
< subscriberid> ; Gmail
< ns1:consumerid xmlns:ns1 =#unknown>
< consumerid> Google
< / headers>
Hi,
In my project i am consuming the java service in .net side . so i have to pass the header . using App.Config i able to pass the header .but i have to remove the App.config file ,without the App.config file i have to pass the header using c# .
For Example :
<bindings>
<basichttpbinding>
<binding name="NewBindng">
<security mode="Transport">
<client>
<endpoint address="http://localhost:8162/Emp/Index">
binding="basicHttpBinding" bindingConfiguration="Newbinding"
contract="MyProject.Service"name="SearchGlobalAssociateV2">
<headers>
<wsse:security xmlns:wsse="#unknown">
<wsse:usernametoken>
<wsse:username>satheesh
<wsse:password>kumar
<ns1:subscriptionenforcement">
<ns1:subscriberid xmlns:ns1="#unknown">
<subscriberid>Gmail
<ns1:consumerid xmlns:ns1="#unknown">
<consumerid>Google
</headers>
推荐答案
这是你需要的一个很好的例子: http://stackoverflow.com/questions/3703844/consume-a-soap-web-service-without-relying-on- -app-config [ ^ ]
这是解决方案。
http://omegacoder.com/?p=1075 [ ^ ]
Here is the solution.
http://omegacoder.com/?p=1075[^]
这篇关于如何将自定义标头传递给c#中的终点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!