Loading ...
Sorry, an error occurred while loading the content.

Getting started with WSDL

Expand Messages
  • haltarac
    Hi All, I am just starting with WSDL & SOAP::Lite (using Lite.pm version 0.65_6 to have som access). I tried a couple of sample client apps: GoogleSearch works
    Message 1 of 2 , Jun 16, 2005
    • 0 Attachment
      Hi All,

      I am just starting with WSDL & SOAP::Lite (using Lite.pm version
      0.65_6 to have som access).

      I tried a couple of sample client apps: GoogleSearch works fine but
      all the message parts in their WSDL are plain simple types as in:

      <message name="doSpellingSuggestion">
      <part name="key" type="xsd:string"/>
      <part name="phrase" type="xsd:string"/>
      </message>

      But I cannot get the Amazon web service (AWS) sample to work :(

      Error message :
      String value expected instead of SOAP::Data reference

      The AWS WSDL looks like:

      <xs:element name="ItemSearch">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="SubscriptionId" type="xs:string" minOccurs="0"/>
      ...
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      ...
      <message name="ItemSearchRequestMsg">
      <part name="body" element="tns:ItemSearch"/> </message>

      and the sample code is like:
      my $aws_handle = SOAP::Lite->service("$aws_wsdl");
      $aws_handle->want_som(1); # I added that

      my $itemsearch_request = SOAP::Data->value(
      SOAP::Data->name('SubscriptionId')->value($susbscription_id),
      ...
      );
      my $som = $aws_handle->ItemSearch($itemsearch_request);

      I tried several other similar experiments trying to reference types
      defined in the WSDL schema section, it usually ends up with:
      Type '' can't be found in a schema class 'SOAP::Serializer'

      I am a bit lost right now... Is there any sample client + wsdl that
      would work with non trivial message parts?

      Thanks for any help...

      Henri.
    • Mark Knoop
      Hi I am trying to get proof of concept SOAP server working but after I introduced an WSDL file I get the fault:
      Message 2 of 2 , Aug 25, 2008
      • 0 Attachment
        Hi

        I am trying to get proof of concept SOAP server working but after I
        introduced an WSDL file I get the fault:

        ##########################################################

        <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
        xmlns:xsi="http://www.w3.or
        g/2001/XMLSchema-instance"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
        ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        soap:encodingStyle="http://sch
        emas.xmlsoap.org/soap/encoding/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/env
        elope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>SO
        APAction shall match 'uri#method' if present (got
        'http://soapdev.g-box.tv/MySOA
        P#getTrue', expected '#getTrue'
        </faultstring></soap:Fault></soap:Body></soap:Envelope>

        ##########################################################

        I tried changing the SOAPAction to '#getTrue' but then I get the fault:

        ##########################################################

        <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
        xmlns:xsi="http://www.w3.or
        g/2001/XMLSchema-instance"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
        ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        soap:encodingStyle="http://sch
        emas.xmlsoap.org/soap/encoding/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/env
        elope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>De
        nied access to method (getTrue) in class (main) at
        C:/Perl/site/lib/SOAP/Lite.pm
        line 2509.
        </faultstring></soap:Fault></soap:Body></soap:Envelope>

        ###########################################################

        The main differences I can see are that in the non WSDL SOAP request we have

        <SOAP-ENV:Body><namesp1:getTrue
        xmlns:namesp1="https://soapdev.g-box.tv/MySOAP"/></SOAP-ENV:Body>

        whereas in the new WSDL version we have

        <SOAP-ENV:Body><getTrue xmlns=""/></SOAP-ENV:Body>

        Is this where the problem lies? If so how can I correct it? Otherwise, what
        else should I be looking at?

        Thanks again
        Mark

        (Code/WSDL follows...)

        Server code:

        #######################

        use strict;
        use SOAP::Transport::HTTP;

        SOAP::Transport::HTTP::CGI
        -> dispatch_to('MySOAP')
        -> handle;

        package MySOAP;

        sub getTrue {

        my $result = {
        description => 'Test Boolean Behaviour - True',
        value => 'true',
        };

        return $result;

        }


        sub getFalse {

        my $result = {
        description => 'Test Boolean Behaviour - False',
        value => 'false',
        };

        return $result;

        }

        1;

        ######################

        WSDL:

        ######################

        <?xml version="1.0" encoding="UTF-8"?>
        <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
        xmlns:tns="https://soapdev.g-box.tv/MySOAP"
        targetNamespace="https://soapdev.g-box.tv/MySOAP">
        <wsdl:types>
        <xs:schema targetNamespace="https://soapdev.g-box.tv/MySOAP"
        elementFormDefault="qualified"/>
        </wsdl:types>
        <wsdl:message name="getTrueRequest"/>
        <wsdl:message name="getTrueResponse">
        <wsdl:part name="description" type="xs:string"/>
        <wsdl:part name="value" type="xs:boolean"/>
        </wsdl:message>
        <wsdl:message name="getFalseRequest"/>
        <wsdl:message name="getFalseResponse">
        <wsdl:part name="description" type="xs:string"/>
        <wsdl:part name="value" type="xs:string"/>
        </wsdl:message>
        <wsdl:portType name="MySOAPPort">
        <wsdl:operation name="getTrue">
        <wsdl:input message="tns:getTrueRequest"/>
        <wsdl:output message="tns:getTrueResponse"/>
        </wsdl:operation>
        <wsdl:operation name="getFalse">
        <wsdl:input message="tns:getFalseRequest"/>
        <wsdl:output message="tns:getFalseResponse"/>
        </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="MySOAPBinding" type="tns:MySOAPPort">
        <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="getTrue">
        <soap:operation soapAction="https://soapdev.g-box.tv/MySOAP#getTrue"/>
        <wsdl:input>
        <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
        <soap:body use="literal"/>
        </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="getFalse">
        <soap:operation soapAction="https://soapdev.g-box.tv/MySOAP#getFalse"/>
        <wsdl:input>
        <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
        <soap:body use="literal"/>
        </wsdl:output>
        </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="MySOAP">
        <wsdl:port name="MySOAPPort" binding="tns:MySOAPBinding">
        <soap:address location="https://soapdev.g-box.tv/demo.pl"/>
        </wsdl:port>
        </wsdl:service>
        </wsdl:definitions>

        ############################################

        Client code:

        ############################################

        use strict;

        #use SOAP::Lite;
        use SOAP::Lite +trace => [qw(method fault transport dispatch result
        parameters headers objects method fault freeform trace
        debug )];


        my $soap = SOAP::Lite
        -> service('https://soapdev.g-box.tv/MySOAP.wsdl');

        {

        my $result = $soap
        ->getTrue();


        while ( my ($key, $value) = each(%$result ) ) {
        print "$key => $value\n";
        }
        }

        {

        my $result = $soap
        ->getFalse();

        while ( my ($key, $value) = each(%$result ) ) {
        print "$key => $value\n";
        }
        }

        ###############################

        Debug excerpt:

        ###############################

        SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x1eef4b4)
        SOAP::Transport::HTTP::Client::send_receive: POST
        https://soapdev.g-box.tv/demo.
        pl
        Accept: text/xml
        Accept: multipart/*
        Content-Length: 411
        Content-Type: text/xml; charset=utf-8
        SOAPAction: "http://soapdev.g-box.tv/MySOAP#getTrue"

        <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        xmlns:xsi="http://www.w
        3.org/1999/XMLSchema-instance"
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/e
        ncoding/" 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><getTrue
        xmlns=""/></SOAP-ENV:Body></SOAP-EN
        V:Envelope>
        SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x210e040)
        SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server
        Error
        Date: Mon, 25 Aug 2008 18:17:10 GMT
        Server: Microsoft-IIS/6.0
        Content-Length: 567
        Content-Type: text/xml; charset=utf-8
        Client-Date: Mon, 25 Aug 2008 18:17:04 GMT
        Client-Peer: 84.234.27.198:443
        Client-Response-Num: 1
        Client-SSL-Cert-Issuer: /CN=GBDEV1
        Client-SSL-Cert-Subject: /CN=GBDEV1
        Client-SSL-Cipher: RC4-MD5
        Client-SSL-Warning: Peer certificate not verified
        SOAPServer: SOAP::Lite/Perl/0.69
        X-Powered-By: ASP.NET

        <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
        xmlns:xsi="http://www.w3.or
        g/2001/XMLSchema-instance"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
        ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        soap:encodingStyle="http://sch
        emas.xmlsoap.org/soap/encoding/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/env
        elope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>SO
        APAction shall match 'uri#method' if present (got
        'http://soapdev.g-box.tv/MySOA
        P#getTrue', expected '#getTrue'
        </faultstring></soap:Fault></soap:Body></soap:Envelope>

        ################################

        Same excerpt from working non WSDL version:

        ################################

        Accept: text/xml
        Accept: multipart/*
        Content-Length: 458
        Content-Type: text/xml; charset=utf-8
        SOAPAction: "https://soapdev.g-box.tv/MySOAP#getTrue"

        <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        xmlns:xsi="http://www.w
        3.org/1999/XMLSchema-instance"
        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/e
        ncoding/" 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><namesp1:getTrue
        xmlns:namesp1="https://soap
        dev.g-box.tv/MySOAP"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
        SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x1a6c4c0)
        SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
        Date: Mon, 25 Aug 2008 16:22:51 GMT
        Server: Microsoft-IIS/6.0
        Content-Length: 581
        Content-Type: text/xml; charset=utf-8
        Client-Date: Mon, 25 Aug 2008 16:22:43 GMT
        Client-Peer: 84.234.27.198:443
        Client-Response-Num: 1
        Client-SSL-Cert-Issuer: /CN=GBDEV1
        Client-SSL-Cert-Subject: /CN=GBDEV1
        Client-SSL-Cipher: RC4-MD5
        Client-SSL-Warning: Peer certificate not verified
        SOAPServer: SOAP::Lite/Perl/0.69
        X-Powered-By: ASP.NET

        <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
        xmlns:xsi="http://www.w3.or
        g/2001/XMLSchema-instance"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
        ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        soap:encodingStyle="http://sch
        emas.xmlsoap.org/soap/encoding/"
        xmlns:soap="http://schemas.xmlsoap.org/soap/env
        elope/"><soap:Body><getTrueResponse
        xmlns="https://soapdev.g-box.tv/MySOAP"><s-g
        ensym3><value xsi:type="xsd:boolean">true</value><descption
        xsi:type="xsd:string
        ">Test Boolean Behaviour -
        True</descption></s-gensym3></getTrueResponse></soap:
        Body></soap:Envelope>

        #################################
      Your message has been successfully submitted and would be delivered to recipients shortly.