Creating a consumer of a Web Service WSDL/SOAP
- by Azzi
I am attempting to write a Windows Desktop App (using WCF) that is a consumer of a web service.
The application:
Sends a SOAP message to a British Government Server to get an authentication token based on the arugments passed
Retrieves a response from that server in the form of a string which contains the authentication token.
I have a template of the SOAP message from the British Government, and a WSDL file for the service.
What I have tried
Add a service reference using the WSDL file. I received the following error: URI formats are not supported.
Add a Web Reference using the URL of the service. I received the following error: The request failed with HTTP status 405: Method Not Allowed.
Send the SOAP request using a POST. The Call to GetResponse() threw a 500 External Server Error.
NOTE: I am using VS 2005
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s1="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication">
<types>
<s:schema elementFormDefault="qualified" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns="https://tpvs.hmrc.gov.uk/dpsauthentication">
<s:element name="DPSrequestToken">
<s:complexType>
<s:sequence>
<s:element name="version" type="s:int"/>
<s:element name="vendorID" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DPSrequestTokenResponse">
<s:complexType>
<s:sequence>
<s:element name="DPSrequestTokenResult" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="DPSrequestTokenSoapIn">
<part name="parameters" element="s1:DPSrequestToken"/>
</message>
<message name="DPSrequestTokenSoapOut">
<part name="parameters" element="s1:DPSrequestTokenResponse"/>
</message>
<portType name="dpsauthenticationSoap">
<operation name="DPSrequestToken">
<input message="s1:DPSrequestTokenSoapIn"/>
<output message="s1:DPSrequestTokenSoapOut"/>
</operation>
</portType>
<binding name="dpsauthenticationSoap" type="s1:dpsauthenticationSoap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="DPSrequestToken">
<soap:operation soapAction="https://tpvs.hmrc.gov.uk/dpsauthentication/DPSrequestToken" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="dpsauthentication">
<port name="dpsauthenticationSoap" binding="s1:dpsauthenticationSoap">
<soap:address location="https://dps.ws.hmrc.gov.uk/dpsauthentication/service"/>
</port>
</service>
</definitions>
SOAP:
<!-- v1.1 30/11/2007 -->
<!-- 24/10/2011 - minor change to remove duplicated text from <Envelope> element. No impact on validation, therefore not re-versioned. -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>as advised by SDS team</wsse:Username>
<wsse:Password>as advised by SDS team</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:DPSrequestToken xmlns:m="https://tpvs.hmrc.gov.uk/dpsauthentication">
<m:version>1</m:version>
<m:vendorID>your 4 digit vendorID</m:vendorID>
</m:DPSrequestToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>