.net调用含SoapHeader的xfire服务

修改WSDL
采取这种方法,把xfire生成的WSDL直接改之,使之具有soapheader信息,直接引入就可以使用。

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.xx.com/services/xxService">  
  
<xsd:element name="AuthenticationToken" type="tns:AuthenticationToken" />  
      <xsd:complexType name="AuthenticationToken">  
        <xsd:sequence>  
          <xsd:element minOccurs="0" maxOccurs="1" name="username" type="xsd:string" />  
      <xsd:element minOccurs="0" maxOccurs="1" name="password" type="xsd:string" />  
        </xsd:sequence>  
        <xsd:anyAttribute />  
      </xsd:complexType>  
</xsd:schema>  
  
...  
  
<wsdl:message name="AuthSoapHeader">  
    <wsdl:part name="AuthenticationToken" element="tns:AuthenticationToken" />  
</wsdl:message>  
  
...  
  
<wsdl:operation name="helloworld">  
      <wsdlsoap:operation soapAction=""/>  
      <wsdl:input name="helloworldRequest">  
        <wsdlsoap:body use="literal"/>  
    <wsdlsoap:header message="tns:AuthSoapHeader" part="AuthenticationToken" use="literal" />  
      </wsdl:input>  
      <wsdl:output name="helloworldResponse">  
        <wsdlsoap:body use="literal"/>  
      </wsdl:output>  
</wsdl:operation>  

你可能感兴趣的:(.net)