I've been tasked with consuming a Perl web service that was written by a
person in a different department of my company. The problem is it's the
guy's first attempt at web services and he doesn't know how to create the
WDSL. I created web service with Visual Studio that mimics his service and
after some tweaking of the soapAction in the WSDL I'm able to call his
service successfully. When I use SOAPScope to look the messages being sent
and received the data is there although my response objects are always null
and I think it's a namespace problem. The Perl web service seems to return a
random namespace every time. If you look at the getURLResponse node in the
XML below you see that the namespace is 'namesp4' and this is different
every time. Is there anyway to change the WSDL to accommodate this? I've
also pasted the WSDL below Any help would be greatly appreciated!
Thanks
RESPONSE:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<namesp4:getURLResponse xmlns:namesp4="urn:/SOAP_URLList">
<url>
<profile xsi:type="xsd:string">custom1</profile>
<position xsi:type="xsd:int">1</position>
<action xsi:type="xsd:int">1</action>
<url xsi:type="xsd:string">http://www.ebay.com</url>
<id xsi:type="xsd:int">124</id>
<enabled xsi:type="xsd:int">1</enabled>
</url>
</namesp4:getURLResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
REQUEST:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getURL xmlns="urn:/SOAP_URLList">
<id>124</id>
</getURL>
</soap:Body>
</soap:Envelope>
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="urn:/SOAP_URLList"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:/SOAP_URLList">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="urn:/SOAP_URLList">
<s:element name="addURL">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="profile" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1"
name="url" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1"
name="action" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1"
name="position" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1"
name="enabled" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="addURLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="addURLResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="updateURL">
<s:complexType/>
</s:element>
<s:element name="updateURLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="updateURLResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getURL">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="id" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getURLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="getURLResult" type="tns:url"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="url">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="profile" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1"
name="action" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1"
name="url" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1"
name="id" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1"
name="enabled" type="s:int"/>
</s:sequence>
</s:complexType>
<s:element name="delURL">
<s:complexType/>
</s:element>
<s:element name="delURLResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1"
name="delURLResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="listURLs">
<s:complexType/>
</s:element>
<s:element name="listURLsResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1"
name="listURLsResult" type="tns:ArrayOfUrl"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfUrl">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded"
name="url" type="tns:url"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="addURLSoapIn">
<wsdl:part name="parameters" element="tns:addURL"/>
</wsdl:message>
<wsdl:message name="addURLSoapOut">
<wsdl:part name="parameters" element="tns:addURLResponse"/>
</wsdl:message>
<wsdl:message name="updateURLSoapIn">
<wsdl:part name="parameters" element="tns:updateURL"/>
</wsdl:message>
<wsdl:message name="updateURLSoapOut">
<wsdl:part name="parameters" element="tns:updateURLResponse"/>
</wsdl:message>
<wsdl:message name="getURLSoapIn">
<wsdl:part name="parameters" element="tns:getURL"/>
</wsdl:message>
<wsdl:message name="getURLSoapOut">
<wsdl:part name="parameters" element="tns:getURLResponse"/>
</wsdl:message>
<wsdl:message name="delURLSoapIn">
<wsdl:part name="parameters" element="tns:delURL"/>
</wsdl:message>
<wsdl:message name="delURLSoapOut">
<wsdl:part name="parameters" element="tns:delURLResponse"/>
</wsdl:message>
<wsdl:message name="listURLsSoapIn">
<wsdl:part name="parameters" element="tns:listURLs"/>
</wsdl:message>
<wsdl:message name="listURLsSoapOut">
<wsdl:part name="parameters" element="tns:listURLsResponse"/>
</wsdl:message>
<wsdl:portType name="SOAP_URLListSoap">
<wsdl:operation name="addURL">
<wsdl:input message="tns:addURLSoapIn"/>
<wsdl:output message="tns:addURLSoapOut"/>
</wsdl:operation>
<wsdl:operation name="updateURL">
<wsdl:input message="tns:updateURLSoapIn"/>
<wsdl:output message="tns:updateURLSoapOut"/>
</wsdl:operation>
<wsdl:operation name="getURL">
<wsdl:input message="tns:getURLSoapIn"/>
<wsdl:output message="tns:getURLSoapOut"/>
</wsdl:operation>
<wsdl:operation name="delURL">
<wsdl:input message="tns:delURLSoapIn"/>
<wsdl:output message="tns:delURLSoapOut"/>
</wsdl:operation>
<wsdl:operation name="listURLs">
<wsdl:input message="tns:listURLsSoapIn"/>
<wsdl:output message="tns:listURLsSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SOAP_URLListSoap" type="tns:SOAP_URLListSoap">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="addURL">
<soap:operation soapAction="urn:/SOAP_URLList#addURL"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="updateURL">
<soap:operation soapAction="urn:/SOAP_URLList#updateURL"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getURL">
<soap:operation soapAction="urn:/SOAP_URLList#getURL"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="delURL">
<soap:operation soapAction="urn:/SOAP_URLList#delURL"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="listURLs">
<soap:operation soapAction="urn:/SOAP_URLList#listURLs"
style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SOAP_URLList">
<documentation xmlns="http://schemas.xmlsoap.org/wsdl/"/>
<wsdl:port name="SOAP_URLListSoap"
binding="tns:SOAP_URLListSoap">
<soap:address location="http://eng-dev:9000"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
TEST CODE:
Dim ws As New SOAP_URLList.SOAP_URLList
Try
Dim url As SOAP_URLList.url = ws.getURL(124)
Dim sf As New _
Serialization.XmlSerializer(GetType(SOAP_URLList.u rl))
Dim sXML As StringWriter = _
New StringWriter(New System.Text.StringBuilder)
sf.Serialize(sXML, url)
Me.txtResponse.Text = sXML.ToString
Catch ex As SoapException
MsgBox(ex.ToString)
Me.txtResponse.Text = ex.ToString
End Try
Returns:
<?xml version="1.0" encoding="utf-16"?>
<url xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />