0
votes

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

  1. Add a service reference using the WSDL file. I received the following error: URI formats are not supported.
  2. 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.
  3. 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>
1
"This is the first time I have written this type of application and I am stuck." That fact that you have posted here notifies all of us that you are stuck. But, in order to help you, we need to know where/why you are stuck. Please post your code and the stack trace(s) for any/all exceptions.Brian
@Brian You can see the code for attempt 3 here: stackoverflow.com/questions/17223771/… Attempt 1 and 2 do not evolve code. And stem from a lack of understanding of Web Services, SOAP, WSDL, VS2005 or the Documentation. A Stack trace would only be relevant to the 3rd thing I have tried as the first two are VS tools and not part of code that is executing.Zzz
If you are using VS2005, then how are you using a service reference?John Saunders
@JohnSaunders When I right click on the project it gives me 'Add Service Reference...' as an option.Zzz
please publish the wsdl and the sample soapYaron Naveh

1 Answers

1
votes

In case someone else runs across the same issue, I was able to solve this issue by using the WSDL.exe program that is normally found in 2. C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\.

This program creates a proxy class for a web service that allows you to call the API's methods localy in your code.

In command line WSDL.exe is called like this: 3.

wsdl http://host/web_service/web_service.asmx?WSDL