in reply to Re^3: using a client SOAP with SOAP::Lite with ComplexType
in thread using a client SOAP with SOAP::Lite with ComplexType

Ok, thank you for your answer. I did what you said and the output was :
SOAP::Serializer::envelope: () SOAP::Serializer::envelope: changeDeliveryState REF(0x862ab9c) 526101 +2 SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x846e +10c) SOAP::Transport::HTTP::Client::send_receive: POST http://my_serv/servi +ces/DeliveryWS?wsdl HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 813 Content-Type: application/soap; charset=utf-8 SOAPAction: "http://my_serv/services/DeliveryWS?wsdl#changeDeliverySta +te" <?xml version="1.0" encoding="UTF-8"?><Envelope xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap +.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml +ns:namesp2="http://namespaces.soaplite.com/perl" soap:encodingStyle=" +http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas +.xmlsoap.org/soap/envelope/"><Body><changeDeliveryState xmlns="http:/ +/my_serv/services/DeliveryWS?wsdl"><c-gensym3><namesp1:Context xmlns: +namesp1="http://my_serv/services/DeliveryWS?wsdl" xsi:type="namesp2"> +<agent xsi:type="xsd:int">1</agent><user xsi:type="xsd:string">jbbec< +/user></namesp1:Context></c-gensym3><c-gensym8 xsi:type="xsd:int">526 +101</c-gensym8><c-gensym10 xsi:type="xsd:int">2</c-gensym10></changeD +eliveryState></Body></Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x874 +712c) SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Ser +ver Error Cache-Control: max-age=0 Connection: close Date: Fri, 12 May 2006 06:18:47 GMT Server: Apache/2.0.46 (Red Hat) mod_jk/1.2.8 mod_ssl/2.0.46 OpenSSL/0. +9.7a Content-Language: fr Content-Type: text/xml;charset=utf-8 Expires: Fri, 12 May 2006 06:18:47 GMT Client-Date: Fri, 12 May 2006 06:20:32 GMT Client-Peer: 10.10.1.4:80 Client-Response-Num: 1 Client-Transfer-Encoding: chunked <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"><soapenv:Header><soapenv:Upgrade +soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mu +stUnderstand="0"><soapenv:SupportedEnvelope qname="soapenv:Envelope"/ +></soapenv:Upgrade></soapenv:Header><soapenv:Body><soapenv:Fault><fau +ltcode>soapenv:VersionMismatch</faultcode><faultstring>Version Mismat +ch</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.or +g/axis/">w1.agen.com</ns1:hostname></detail></soapenv:Fault></soapenv +:Body></soapenv:Envelope> SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () SOAP::SOM::new: () SOAP::Lite::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Parser::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Serializer::DESTROY: () Version MismatchSOAP::SOM::DESTROY: ()
I could see that the version of soap in my client was not 1.2, then commented the line in my client
#$soap->soapversion(1.2);
and i re-run the client and obtain this trace :
SOAP::Transport::HTTP::Client::send_receive: POST http://my_serv/servi +ces/DeliveryWS?wsdl HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 833 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://my_serv/services/DeliveryWS?wsdl#changeDeliverySta +te" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xm +lsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema +" xmlns:namesp2="http://namespaces.soaplite.com/perl" soap:encodingSt +yle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://sc +hemas.xmlsoap.org/soap/envelope/"><soap:Body><changeDeliveryState xml +ns="http://my_serv/services/DeliveryWS?wsdl"><c-gensym3><namesp1:Cont +ext xmlns:namesp1="http://my_serv/services/DeliveryWS?wsdl" xsi:type= +"namesp2"><agent xsi:type="xsd:int">1</agent><user xsi:type="xsd:stri +ng">jbbec</user></namesp1:Context></c-gensym3><c-gensym8 xsi:type="xs +d:int">526101</c-gensym8><c-gensym10 xsi:type="xsd:int">2</c-gensym10 +></changeDeliveryState></soap:Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x874 +70b0) SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Ser +ver Error Cache-Control: max-age=0 Connection: close Date: Fri, 12 May 2006 07:50:31 GMT Server: Apache/2.0.46 (Red Hat) mod_jk/1.2.8 mod_ssl/2.0.46 OpenSSL/0. +9.7a Content-Language: fr Content-Type: text/xml;charset=utf-8 Expires: Fri, 12 May 2006 07:50:31 GMT Client-Date: Fri, 12 May 2006 07:52:15 GMT Client-Peer: 10.10.1.4:80 Client-Response-Num: 1 Client-Transfer-Encoding: chunked <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><fau +ltcode>soapenv:Server.userException</faultcode><faultstring>org.xml.s +ax.SAXException: Invalid element in com.delivery.middle.bean.fake.Con +text - Context</faultstring><detail><ns1:hostname xmlns:ns1="http://x +ml.apache.org/axis/">w1.agen.com</ns1:hostname></detail></soapenv:Fau +lt></soapenv:Body></soapenv:Envelope> SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () SOAP::SOM::new: () SOAP::Lite::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Parser::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Serializer::DESTROY: () org.xml.sax.SAXException: Invalid element in com.delivery.middle.bean. +fake.Context - ContextSOAP::SOM::DESTROY: ()

Replies are listed 'Best First'.
Re^5: using a client SOAP with SOAP::Lite with ComplexType
by gellyfish (Monsignor) on May 12, 2006 at 08:18 UTC

    Well it would be better if we could see the whole WSDL for the service but I think the problem is with the <c-gensym3 /> around the <Context /> element - you can lose that by not using the extra SOAP::Data as I described above; it is also possible that you need to supply specific names for the other 'arguments' to changeDeliveryState which is better described in the WSDL.

    /J\

      I can't show you the whole WSDL file but only a few line :
      <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apac +hesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNam +espace" xmlns:intf="http://DefaultNamespace" xmlns:soapenc="http://sc +hemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://fake.bean.middle +.delivery.agen.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xml +ns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http:/ +/www.w3.org/2001/XMLSchema"> <!--WSDL created by Apache Axis version: 1.2RC2 Built on Nov 16, 2004 (12:19:44 EST)--> <wsdl:types> <schema targetNamespace="http://fake.bean.middle.delivery.agen.com" +xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="Context"> <sequence> <element name="agent" type="xsd:boolean"/> <element name="deliveryBlockedByApproval" type="xsd:boolean"/> <element name="fiabilisation" type="xsd:boolean"/> <element name="fromDispatch" type="xsd:boolean"/> <element name="fromEmission" type="xsd:boolean"/> <element name="fromSite" type="xsd:boolean"/> <element name="hasComment" nillable="true" type="soapenc:string"/ +> <element name="hasMetaDossier" nillable="true" type="soapenc:stri +ng"/> <element name="market" nillable="true" type="soapenc:string"/> <element name="mdHasConstraints" type="xsd:boolean"/> <element name="user" nillable="true" type="soapenc:string"/> </sequence> </complexType> . . . </schema> </wsdl:types> . . . <wsdl:message name="changeDeliveryStateRequest"> <wsdl:part name="in0" type="tns1:Context"/> <wsdl:part name="in1" type="xsd:long"/> <wsdl:part name="in2" type="xsd:long"/> </wsdl:message> . . . <wsdl:portType name="DeliveryServiceInterface"> <wsdl:operation name="changeDeliveryState" parameterOrder="in0 i +n1 in2"> <wsdl:input message="impl:changeDeliveryStateRequest" name="c +hangeDeliveryStateRequest"/> <wsdl:output message="impl:changeDeliveryStateResponse" name= +"changeDeliveryStateResponse"/> </wsdl:operation> . . . </ </wsdl:portType> <wsdl:definitions>
      juste let me know if you need more..cause it's from my work...;)
        Yes i did it !! in fact i had 2 problems :
        - the first was the creation of the complexType
        - the second the type of the other params ( long in the prototype) was translated as int in the enveloppe.
        First issue :

        the solution is :
        This ComplexType mod is simpler than the first i wrote (at the biginning of this thread) :
        package ContextType; use strict; use warnings; use SOAP::Data::ComplexType; use vars qw(@ISA); @ISA = qw(SOAP::Data::ComplexType); use constant OBJ_URI => 'http://w1.agen.com/services/DeliveryWS'; use constant OBJ_TYPE => 'ns1:Context'; use constant OBJ_FIELDS => { user => ['soapenc:string', undef, undef], agent => ['xsd:boolean', undef, undef], }; sub new { my $proto = shift; my $class = ref($proto) || $proto; my $data = shift; my $obj_fields = shift; $obj_fields = defined $obj_fields && ref($obj_fields) eq 'HASH' +? {%{$obj_fields}, %{+OBJ_FIELDS}} : OBJ_FIELDS; my $self = $class->SUPER::new($data, $obj_fields); return bless($self, $class); }
        now, the enveloppe that i send looks like :
        <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xm +lsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema +" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmln +s:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><change +DeliveryState xmlns="http://w1.agen.com/services/DeliveryWS"><c-gensy +m3><agent xsi:type="xsd:boolean">1</agent><user xsi:type="soapenc:str +ing">jbbec</user></c-gensym3><c-gensym7 xsi:type="xsd:long">526101</c +-gensym7><c-gensym9 xsi:type="xsd:long">2</c-gensym9></changeDelivery +State></soap:Body></soap:Envelope>
        For the second issue, i found a dirty workaround in the Lite.pm file.
        In fact all the int are long
        'int' => [25, sub {$_[0] =~ /^[+-]?(\d+)$/ && $1 >= -214748 +3648;}, 'as_long'], 'long' => [20, sub {$_[0] =~ /^[+-]?(\d+)$/ && $1 >= -214748 +3648; }, 'as_long'],
        I will change this very very dirty thing to a better one later, maybe this WE.