Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WSDL中的Soap客户端:添加ws-security头_C#_.net_Wcf_Soap_Wcf Data Services - Fatal编程技术网

C# WSDL中的Soap客户端:添加ws-security头

C# WSDL中的Soap客户端:添加ws-security头,c#,.net,wcf,soap,wcf-data-services,C#,.net,Wcf,Soap,Wcf Data Services,在c控制台项目中,我添加了来自wsdl的服务引用 在应用程序配置中,我有以下xml代码: <bindings> <basicHttpBinding> <binding name="verificaValiditaPatenteSoap11" /> </basicHttpBinding> </bindings> <client> <endpoint address="http

在c控制台项目中,我添加了来自wsdl的服务引用

在应用程序配置中,我有以下xml代码:

<bindings>
     <basicHttpBinding>
         <binding name="verificaValiditaPatenteSoap11" />
     </basicHttpBinding>
</bindings>
<client>
    <endpoint address="http://myurl.com/services/myservice"
            binding="basicHttpBinding" bindingConfiguration="xxxxxxxx"
            contract="xxxxxx" name="xxxxxx" />
</client>
当我看到请求的输出时,我没有wsse头。 我需要在请求的消息中包含以下标题。我怎样才能做到这一点?如何添加ws-security?有教程吗

<soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-91C0647D2779DF588C14621957892417"><wsse:Username>MyUsername</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MyPassword</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header>

要获得一些实际指导,您应该查看Scott Hanselman的博客,这里是一篇关于WS-Security的文章:

微软的模式和实践解决了WS-Security的基本问题:

无论如何,您可以开始在服务中包括安全传输,并将其添加到您的配置文件中:

<binding name="verificaValiditaPatenteSoap11">
      <security mode="TransportWithMessageCredential" />
</binding>
因此,您将能够找到WS-Security标头

希望能有帮助