2009-11-03 128 views
1

我试图消耗第三方web服务(从组件接口中的Peoplesoft),但为了验证我必须有一个头,看起来像这样:web服务安全头

<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 

    <wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">  
     <wsse:UsernameToken>  
     <wsse:Username>X</wsse:Username>  
     <wsse:Password>X</wsse:Password>  
     </wsse:UsernameToken>  
    </wsse:Security>  
    </soapenv:Header> 

我加了块在我的应用程序中的web.config文件,该文件要使用的web服务如下:

<system.serviceModel> 
     <client> 
      <header> 
       <endpoint> 
        <wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
         <wsse:UsernameToken> 
          <wsse:Username>X</wsse:Username> 
          <wsse:Password>X</wsse:Password> 
         </wsse:UsernameToken> 
        </wsse:Security> 
       </endpoint> 
      </header> 
     </client> 
</system.serviceModel> 

但头仍然没有出现在XML请求到web服务。

我是否在正确的轨道?

回答

0

如果您使用.NET 2.0连接到该服务,最好的办法是下载WSE 3.0(如果您使用的是.NET 1.1,则为WSE 2.0)。

如果您使用WCF连接到服务,这里有一个链接应该可以帮助您。这是关于适当的方式来实现在WCF的WS-Security标准:

Enterprise .NET Community: Security your WCF Services

+0

据我所知,以上都不是。我在Visual Studio 2008(.NET 3.5)中添加了一个Web引用。 – jhunter 2009-11-03 20:56:31

+0

然后,如果我没有记错,默认行为应该是创建WCF绑定到Web服务。 – 2009-11-03 21:28:56