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

SOAP::Lite + JBoss Question (Parameter Not Being Sent)

Expand Messages
  • David Lloyd
    I have: SOAP::Lite 0.710.08 ...running on: This is perl, v5.10.0 built for i486-linux-gnu-thread-multi ...against this WSDL (which I ve also copied and pasted
    Message 1 of 3 , Jul 14, 2009
    • 0 Attachment
      I have:

      SOAP::Lite 0.710.08

      ...running on:

      This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

      ...against this WSDL (which I've also copied and pasted into this
      message):

      http://users.adam.com.au/lloy0076/soap_test.wsdl

      ...I have this code:

      ## BEGIN PERL CODE

      use SOAP::Lite +trace => qw(debug);
      import SOAP::Data qw(name);

      my $service =
      SOAP::Lite->service("http://127.0.0.1:8080/SoapTest/TestService?wsdl");
      $service->readable(1);

      my $name = SOAP::Data->new(name => "HelloWorld2", value => "Ulysses S
      Grant");
      #die $name->name;

      my $result3 = $service->HelloWorld2($name);

      ##

      But my Java web service acts as though the parameter called HelloWorld2
      does not exist. The same happens if I change the name from HelloWorld2
      to just name (i.e. name => "name").

      SOAP::Transport::HTTP::Client::send_receive: POST
      http://127.0.0.1:8080/SoapTest/TestService HTTP/1.1
      Accept: text/xml
      Accept: multipart/*
      Accept: application/soap
      Content-Length: 553
      Content-Type: text/xml; charset=utf-8
      SOAPAction: ""

      <?xml version="1.0" encoding="UTF-8"?>
      <soap:Envelope
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="http://adam.com.au/">
      <soap:Body>
      <tns:HelloWorld2>
      <HelloWorld2 xsi:nil="true" xsi:type="tns:HelloWorld2" />
      </tns:HelloWorld2>
      </soap:Body>
      </soap:Envelope>

      From this output, SOAP::Lite seems to think that the HelloWorld2 message
      part is empty or nil - it returned "Hello, None Passed!" (which is what
      my Java code does if its parameter is null).

      Interestingly, if I use the same code but point it at Sun's Glassfish V2
      (or SJSAS v9) application server, I get back "Hello, Ulysses S Grant!".

      I *think* it's some issue with the WSDL which strikes me as valid (I've
      looked at the specification for WSDL itself and it seems to think that
      the WSDL is valid from what I can tell). I suspect that SOAP::Lite is
      parsing the WSDL correctly but I'm not passing it the right "thing",
      "object" or "set of values" for it to fill in the HelloWorld2 or name
      method.

      Anyone got a clue as to what's happening?

      DSL

      [1] WSDL

      <definitions name='TestServiceService'
      targetNamespace='http://adam.com.au/'
      xmlns='http://schemas.xmlsoap.org/wsdl/'
      xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
      xmlns:tns='http://adam.com.au/'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
      <types>
      <xs:schema targetNamespace='http://adam.com.au/' version='1.0'
      xmlns:tns='http://adam.com.au/'
      xmlns:xs='http://www.w3.org/2001/XMLSchema'>
      <xs:element name='HelloWorld' type='tns:HelloWorld'/>
      <xs:element name='HelloWorld2' type='tns:HelloWorld2'/>
      <xs:element name='HelloWorld2Response'
      type='tns:HelloWorld2Response'/>
      <xs:element name='HelloWorldResponse' type='tns:HelloWorldResponse'/>
      <xs:complexType name='HelloWorld'>
      <xs:sequence/>

      </xs:complexType>
      <xs:complexType name='HelloWorldResponse'>
      <xs:sequence>
      <xs:element minOccurs='0' name='return' type='xs:string'/>
      </xs:sequence>
      </xs:complexType>
      <xs:complexType name='HelloWorld2'>
      <xs:sequence>
      <xs:element minOccurs='0' name='name' type='xs:string'/>

      </xs:sequence>
      </xs:complexType>
      <xs:complexType name='HelloWorld2Response'>
      <xs:sequence>
      <xs:element minOccurs='0' name='return' type='xs:string'/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      </types>

      <message name='TestService_HelloWorld'>
      <part element='tns:HelloWorld' name='HelloWorld'></part>
      </message>
      <message name='TestService_HelloWorld2'>
      <part element='tns:HelloWorld2' name='HelloWorld2'></part>
      </message>
      <message name='TestService_HelloWorld2Response'>
      <part element='tns:HelloWorld2Response'
      name='HelloWorld2Response'></part>
      </message>

      <message name='TestService_HelloWorldResponse'>
      <part element='tns:HelloWorldResponse'
      name='HelloWorldResponse'></part>
      </message>
      <portType name='TestService'>
      <operation name='HelloWorld' parameterOrder='HelloWorld'>
      <input message='tns:TestService_HelloWorld'></input>
      <output message='tns:TestService_HelloWorldResponse'></output>
      </operation>
      <operation name='HelloWorld2' parameterOrder='HelloWorld2'>

      <input message='tns:TestService_HelloWorld2'></input>
      <output message='tns:TestService_HelloWorld2Response'></output>
      </operation>
      </portType>
      <binding name='TestServiceBinding' type='tns:TestService'>
      <soap:binding style='document'
      transport='http://schemas.xmlsoap.org/soap/http'/>
      <operation name='HelloWorld'>
      <soap:operation soapAction=''/>
      <input>

      <soap:body use='literal'/>
      </input>
      <output>
      <soap:body use='literal'/>
      </output>
      </operation>
      <operation name='HelloWorld2'>
      <soap:operation soapAction=''/>
      <input>

      <soap:body use='literal'/>
      </input>
      <output>
      <soap:body use='literal'/>
      </output>
      </operation>
      </binding>
      <service name='TestServiceService'>
      <port binding='tns:TestServiceBinding' name='TestServicePort'>

      <soap:address location='http://127.0.0.1:8080/SoapTest/TestService'/>
      </port>
      </service>
      </definitions>

      [2] Java Program

      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */

      package au.com.adam;

      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebService;

      /**
      *
      * @author lloy0076
      */
      @WebService()
      public class TestService {

      /**
      * Web service operation
      */
      @WebMethod(operationName = "HelloWorld")
      public String HelloWorld() {
      return "Hello, World!";
      }

      /**
      * Web service operation
      */
      @WebMethod(operationName = "HelloWorld2")
      public String HelloWorld2(@WebParam(name = "name")
      String name) {
      if (name == null) {
      name = "None Passed";
      }
      return "Hello, " + name + "!";
      }
      }
    • rahed
      ... Generating xml from wsdl with complex types doesn t work and is not maintained (I think). Your wsdl is quite simple, you can work it out like this: $client
      Message 2 of 3 , Jul 16, 2009
      • 0 Attachment
        On Tue, Jul 14, 2009 at 9:23 AM, David Lloyd<Lloy0076@...> wrote:

        > ## BEGIN PERL CODE
        >
        > use SOAP::Lite +trace => qw(debug);
        > import SOAP::Data qw(name);
        >
        > my $service =
        > SOAP::Lite->service("http://127.0.0.1:8080/SoapTest/TestService?wsdl");
        > $service->readable(1);
        >
        > my $name = SOAP::Data->new(name => "HelloWorld2", value => "Ulysses S
        > Grant");
        > #die $name->name;
        >
        > my $result3 = $service->HelloWorld2($name);

        Generating xml from wsdl with complex types doesn't work and is not
        maintained (I think).

        Your wsdl is quite simple, you can work it out like this:

        $client = SOAP::Lite->new(
        'uri' =>('http://adam.com.au'),
        'proxy' =>('http://your/service'),
        );
        $client->on_action(sub{ '' });
        $client->readable(1);


        $sobj = SOAP::Data->name(name => 'Ulysses S Grant');

        $data = $client->HelloWorld2($sobj);
        # if matching
        if ($match = $data->match('/Envelope/Body/HelloWorld2Response')) {
        print "match OK: [$match]\n";
        $return = $data->valueof('//HelloWorld2Response/return');
        # ...
        } else {
        print "match not OK: [$match]\n";
        }


        --
        Radek
      • rahed
        ... If you want to avoid constructing the xml manually, try these modules: XML::Compile::SOAP or SOAP::WSDL -- Radek
        Message 3 of 3 , Jul 28, 2009
        • 0 Attachment
          On Tue, Jul 28, 2009 at 9:17 AM, David Lloyd<Lloy0076@...> wrote:

          > I really wanted to use the WSDL because, well, that's what the WSDL is meant
          > to allow you to do :)

          If you want to avoid constructing the xml manually, try these modules:

          XML::Compile::SOAP or
          SOAP::WSDL


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