Web services 如何将WSSE头添加到Web服务客户端?

Web services 如何将WSSE头添加到Web服务客户端?,web-services,header,ws-security,soapheader,Web Services,Header,Ws Security,Soapheader,我想将wsse安全头添加到ASP 3.5上的web服务客户端。我使用这个Soap信封从SoapUI测试web服务,并得到一个答案: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:comp="http://myCompany.org.tr"> <soapenv:Header xmlns:env="http://schemas.xmlsoap.org/soap/

我想将wsse安全头添加到ASP 3.5上的web服务客户端。我使用这个Soap信封从SoapUI测试web服务,并得到一个答案:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:comp="http://myCompany.org.tr">   <soapenv:Header xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
 <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
 <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
 <wsse:Username>MyUsername</wsse:Username>
 </wsse:Security>
</soapenv:Header>
<soapenv:Body>
    (Body Info.)

   </soapenv:Body>

</soapenv:Envelope>

我的用户名
(身体信息)

我想通过VisualStudi2012创建的经典Web服务引用创建此信封。我应该使用哪个类将用户名信息添加到信封中?

谢谢John和Ladislav


事实证明,您应该通过web.config文件添加标题以获得正确排序的SOAP消息。否则,.Net会尝试用自己的封装(即使您不要求)嵌套您的代码,并因此发送一些垃圾。

您必须通过自定义SOAP头或自定义SOAP扩展手动添加它。将您自己的答案标记为正确似乎是错的。