in reply to Re^2: SOAP::Lite method with one param
in thread SOAP::Lite method with one param

What are you talking about?

What I linked before in Re: SOAP::Lite additional namespace shows how to craft SOAP the way you want ... complete self contained code

The most recent tips in Re: SOAP::Lite method with one param cover getting "<S:Body>" instead of "<soap:Body>"...

If this isn't helping, post some code like Re: Problems with SOAP::Lite client with debugging aid $soap->transport->add_handler("request_send", \&pp_dump );

Replies are listed 'Best First'.
Re^4: SOAP::Lite method with one param
by montaseri (Initiate) on Jan 22, 2015 at 02:22 UTC
    Yes, perhaps I should post a complete question:

    My WSDL reads:

    <wsdl:message name="getAllLocalGroupsIn"> <wsdl:part name="parameter" element="tns:getAllLocalGroups"/> </wsdl:message> <wsdl:message name="getAllLocalGroupsOut"> <wsdl:part name="parameter" element="tns:getAllLocalGroupsResp +onse"/> </wsdl:message>
    And then
    <wsdl:portType name="LocalGroupProviderPortType"> <wsdl:operation name="getAllLocalGroups"> <wsdl:input message="tns:getAllLocalGroupsIn"/> <wsdl:output message="tns:getAllLocalGroupsOut"/> </wsdl:operation>
    and yet then
    <wsdl:binding name="LocalGroupProviderBinding" type="tns:LocalGrou +pProviderPortType"> <soap:binding style="document" transport="http://schemas.xmlso +ap.org/soap/http"/> <wsdl:operation name="getAllLocalGroups"> <soap:operation soapAction="" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output>
    My XSD files has
    <xs:element name="getAllLocalGroups" type="xs:unsignedShort"/> <xs:element name="getAllLocalGroupsResponse"> <xs:complexType> <xs:sequence> <xs:element name="localGroups" type="ns1:LocalGroup" m +axOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element>
    Note: how the input is not a complexType.

    A JAX-WS client is generating the fllowing payload by parsing this WSDL and Schema file(s).

    <?xml version="1.0" ?><S:Envelope xmlns:S="http://www.w3.org/2003/05/s +oap-envelope"><S:Body><getAllLocalGroups xmlns="http://www.bluearc.co +m/BAService/LocalGroupProvider" xmlns:ns2="http://www.bluearc.com/BAS +ervice/LocalGroupProvider/Types">0</getAllLocalGroups></S:Body></S:En +velope>
    Note how value of 0 (zero) is placed in element getAllLocalGroups which is the methodName.

    In my Perl client I write the following....I am skipping some generic send request parts...

    # ------------------- getAllLocalGroups() ---------------------------- sub LocalGroupProvider::getAllLocalGroups() { my $this = shift; my ($rawJson, $methodRef, $inputRef) = @_; my $method = SOAP::Data->new( 'name' => $this->{'Hyas'}->getMethod(), 'prefix' => 'ns0' ); my $provider = $this->{'Hyas'}->getProvider(); $method->attr({ 'xmlns:ns0' => "http://www.bluearc.com/BAService/$provider +" }); $$methodRef = $method; my $jbuf = {}; if ( $rawJson ) { my $job = JSON->new(); $jbuf = $job->decode($rawJson); } my $evsId = SOAP::Data->new( 'name' => 'evsId', 'value' => $jbuf->{'evsId'}, 'prefix' => 'ns0', 'type' => 'unsignedShort' ); @$inputRef = ($evsId); return(1); } # --------------------------------------------------------------------
    Which generates the following payload
    <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:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns0:getAllLocalGroups xmlns:ns0="http://www.bluearc.com/BAService +/LocalGroupProvider"> <ns0:evsId xsi:type="xsd:unsignedShort">0</ns0:evsId> </ns0:getAllLocalGroups> </soap:Body> </soap:Envelope>
    And my gSOAP server gives me the following error
    faultString = Validation constraint violation: data type mismatch in +element <ns0:getAllLocalGroups> faultCode = SOAP-ENV:Client
    So the difference is that the working WSDL and JAX client are sending
    <methodName>paramValue</methodName>
    where as my perl client is sending
    <methodName> <paramName>paramValue</paramName> </methodName>
    And I am trying to find a way with SOAP::Lite to send what JAX client is sending.
      That is not self contained like this
      #!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; my $soap = SOAP::Lite -> uri('http://127.0.0.1/MyModule') -> proxy('http://127.0.0.1:1203') ;;;;;;;;; $soap->transport->add_handler("request_send", \&pp_dump ); $soap->transport->add_handler("response_done", \&pp_dump ); ); $soap->autotype(0)->readable(1); $soap->serializer->envprefix('S'); $soap->ns( "http://www.bluearc.com/BAService/LocalGroupProvider" , 'ns +0' ); my $evsId = SOAP::Data->new( 'name' => 'evsId', 'value' => 'evsId', 'prefix' => 'ns0', 'type' => 'unsignedShort' ); $soap->call( 'getAllLocalGroups', $evsId ); sub pp_twig { use XML::Twig; open my($fh), '>', \my $str; no warnings 'newline'; #~ XML::Twig->new(qw! pretty_print record !)->xparse(@_)->print( $ +fh ); XML::Twig->new(qw! pretty_print record !)->parse(@_)->print( $fh ) +; $str =~ s/ xmlns/\n xmlns/g; return $str; } sub pp_dump { my $content = $_[0]->content(''); $_[0]->content( pp_twig($content) ); print $_[0]->as_string,"\n"; return; } __END__ POST http://127.0.0.1:1203 HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/1.11 Content-Length: 573 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://www.bluearc.com/BAService/LocalGroupProvider#getAl +lLocalGroups" <?xml version="1.0" encoding="UTF-8"?> <S:Envelope S:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/ +" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://www.bluearc.com/BAService/LocalGroupProvider" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <S:Body> <ns0:getAllLocalGroups> <ns0:evsId xsi:type="xsd:unsignedShort">evsId</ns0:evsId> </ns0:getAllLocalGroups> </S:Body> </S:Envelope>
        I see that your code is generating
        <S:Body> <ns0:getAllLocalGroups> <ns0:evsId xsi:type="xsd:unsignedShort">evsId</ns0:evsId> </ns0:getAllLocalGroups> </S:Body>
        I would like to generate this
        <S:Body> <ns0:getAllLocalGroups> 1 </ns0:getAllLocalGroups> </S:Body>
        Please show me how you would use SOAP::Lite to generate that.

        Again, note there is no element called evsId, the value of evsId is placed in an element that is also the methodName, that of "getAllLocalGroups".