none
Web Service Header Authentication RRS feed

  • Question

  • Hi,

    I'm using Visual Studio 2010 and have added a web reference to a WSDL as shown below. The authentication policy is included in the WSDl but for some reason Visual Studio is not auto-generating any proxy classes for the authentication types. Basically each time I send a SOAP message I need the option of including authentication information in the header of the message. Authentication is not required as a seperate method.

    So I've thought of 2 options:

    - Add some code that inserts the header information in the SOAP message before a SOAP message is sent. I am a bit stuck on how to do this as I can't edit the reference.cs file (containing the proxy classes) since each time I rebuild my solution it will just overwrite any changes I have made.

    - Get the WSDL provider to modify the WSDL somehow to auto-generate the required proxy classes for authentication. If this case is easier what exactly would the WSDL provider need to modify in order for Visual Studio to auto-generate the authentication classes and include (if logged in) / don't include (if not logged in) it in each SOAP message. Would the xsd file need to be modified?

    I've also saved the WSDL and XSD locally and when I try to run it using VS command prompt and generate the proxy class it generates the proxy class but I get this error/warning, not sure if this is the reason why the authentication class is not auto-generated:

    Warning: This web reference does not conform to WS-I Basic Profile v1.1.
    R2028, R2029: A DESCRIPTION using the WSDL namespace and the WSDL SOAP binding n
    amespace MUST be valid according to the XML Schemas found at http://schemas.xmls
    oap.org/wsdl/2003-02-11.xsd and http://schemas.xmlsoap.org/wsdl/soap/2003-02-11.
    xsd.
      -  Warning: The element 'definitions' in namespace 'http://schemas.xmlsoap.org
    /wsdl/' has invalid child element 'Policy' in namespace 'http://schemas.xmlsoap.
    org/ws/2004/09/policy'. List of possible elements expected: 'import, types, mess
    age, portType, binding, service' in namespace 'http://schemas.xmlsoap.org/wsdl/'
    . Line 78, position 6.

    Thanks in advance

    WSDL:

    <s0:definitions xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s2="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s1="http://rsm.govt.nz/smart/download" name="DownloadLicences?xsd=LicenceDownloadService.xsd" targetNamespace="http://rsm.govt.nz/smart/download">
      <s0:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://rsm.govt.nz/smart/download" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://rsm.govt.nz/smart/download">
          <!-- Licence Download Service XSD Include -->
          <xs:include schemaLocation="LicenceDownloadService.xsd"/>
        </xs:schema>
      </s0:types>
      <s0:message name="LicenceDownloadException">
        <s0:part name="errorMessage" element="s1:errorMessage">
        </s0:part>
      </s0:message>
      <s0:message name="msgDetailResponse">
        <s0:part name="detailResponse" element="s1:Licence">
        </s0:part>
      </s0:message>
      <s0:message name="msgSearchResponse">
        <s0:part name="searchResponse" element="s1:SearchResult">
        </s0:part>
      </s0:message>
      <s0:message name="msgSearch">
        <s0:part name="arg0" element="s1:SearchCriteria">
        </s0:part>
      </s0:message>
      <s0:message name="msgDetail">
        <s0:part name="arg0" element="s1:LicenceDetailsRequest">
        </s0:part>
      </s0:message>
      <s0:portType name="LicenceDownloadWebService">
        <s0:operation name="searchLicences">
          <s0:input message="s1:msgSearch">
        </s0:input>
          <s0:output message="s1:msgSearchResponse">
        </s0:output>
          <s0:fault name="licenceDownloadException" message="s1:LicenceDownloadException">
        </s0:fault>
        </s0:operation>
        <s0:operation name="getLicenceDetails">
          <s0:input message="s1:msgDetail">
        </s0:input>
          <s0:output message="s1:msgDetailResponse">
        </s0:output>
          <s0:fault name="licenceDownloadException" message="s1:LicenceDownloadException">
        </s0:fault>
        </s0:operation>
      </s0:portType>
      <s0:binding name="LicenceDownloadServiceBinding" type="s1:LicenceDownloadWebService">
        <s2:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <s0:operation name="getLicenceDetails">
          <s2:operation soapAction="getLicenceDetails" style="document"/>
          <s0:input>
            <s2:body use="literal"/>
          </s0:input>
          <s0:output>
            <s2:body use="literal"/>
          </s0:output>
          <s0:fault name="licenceDownloadException">
            <s2:fault name="licenceDownloadException" use="literal"/>
          </s0:fault>
        </s0:operation>
        <s0:operation name="searchLicences">
          <s2:operation soapAction="searchLicences" style="document"/>
          <s0:input>
            <s2:body use="literal"/>
          </s0:input>
          <s0:output>
            <s2:body use="literal"/>
          </s0:output>
          <s0:fault name="licenceDownloadException">
            <s2:fault name="licenceDownloadException" use="literal"/>
          </s0:fault>
        </s0:operation>
      </s0:binding>
      <s0:service name="LicenceDownloadService">
        <s0:port name="LicenceDownloadServicePort" binding="s1:LicenceDownloadServiceBinding">
          <s2:address location="https://data.business.govt.nz/services/DownloadLicences"/>
        </s0:port>
      </s0:service>
        <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UTOverTransport">
    		<wsp:ExactlyOne>
    			<wsp:All>
    				<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
    					<wsp:Policy>
    						<sp:TransportToken>
    							<wsp:Policy>
    								<sp:HttpsToken RequireClientCertificate="false"/>
    							</wsp:Policy>
    						</sp:TransportToken>
    						<sp:AlgorithmSuite>
    							<wsp:Policy>
    								<sp:Basic256/>
    							</wsp:Policy>
    						</sp:AlgorithmSuite>
    						<sp:Layout>
    							<wsp:Policy>
    								<sp:Lax/>
    							</wsp:Policy>
    						</sp:Layout>
    					</wsp:Policy>
    				</sp:TransportBinding>
    				<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
    					<wsp:Policy>
    						<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"/>
    					</wsp:Policy>
    				</sp:SignedSupportingTokens>
    			</wsp:All>
    		</wsp:ExactlyOne>
    	</wsp:Policy>
    </s0:definitions>

    • Moved by George Hua Tuesday, January 14, 2014 8:31 AM Web services related
    Monday, January 13, 2014 10:14 PM

All replies

  • Hi,

    Welcome to MSDN forum.

    Since your question is more related to Web services, I would move this thread to Windows Communication Foundation, Serialization, and Networking forum for more effective responses.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 14, 2014 8:30 AM