I am using perl soap :: lite to create a web services client. The implementation works great for simple methods that will, for example, require one scalar argument. EG then works fine.
#!/usr/bin/perl use warnings; use SOAP::Lite +trace=>debug; use strict; use Data::Dumper; $SOAP::Constants::PREFIX_ENV = 'SOAP-ENV'; my $base="https://XXXX:60001/GDBIncidentWebService/Config?wsdl&style=rpc"; my $user="XXXX"; my $pwd="XXXX"; my $lite = SOAP::Lite -> readable(1) -> service($base) ; my @res=$lite->readIncident("123456"); print Dumper(\@res); exit; sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pwd ; }
I need to call one method that requires a more complex set of arguments (multiple scalars plus one array of key-value pairs). I believe that I should use the SOAP :: Data module to properly serialize my data, but cannot make it work. Even the βsimpleβ methods (for example, above) do not work. EG (simply showing the lines modified at the top of the script):
my $arg= SOAP::Data->new()->type('xs:string')-> value("20054106"); my @res=$lite->readIncident($arg);
Productivity:
String value expected instead of SOAP::Data reference
Any idea on how to fix this? Many thanks! For reference: wsdl for a method called in my script
<wsdl:operation name="readIncident"> <soap:operation soapAction=""/> <wsdl:input> <soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi" parts="ticketID "/> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi"/> </wsdl:output> </wsdl:operation>
Full WSDL is as follows - spreads over 3 files. Main WSDL file:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="GDBIncidentWebServiceWsd" targetNamespace="urn:GDBIncidentWebServiceWsd" xmlns:bns0="urn:GDBIncidentWebServiceWsd/Config/rpc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <wsdl:import location="./bindings/Config_rpc.wsdl" namespace="urn:GDBIncidentWebServiceWsd/Config/rpc"/> <wsdl:service name="GDBIncidentWebService"> <wsdl:port name="ConfigPort_Rpc" binding="bns0:ConfigBinding"> <soap:address location="http://xxxx/GDBIncidentWebService/Config?style=rpc"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Binding File (Extract)
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ns0="urn:com.dbag.gde.gdb.types" targetNamespace="urn:GDBIncidentWebServiceWsd/GDBIncidentWebServiceVi/rpc" xmlns:tns="urn:GDBIncidentWebServiceWsd/GDBIncidentWebServiceVi/rpc" xmlns:ns2="urn:java/lang"> <wsdl:types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:com.dbag.gde.gdb.types" xmlns:tns="urn:com.dbag.gde.gdb.types" elementFormDefault="qualified"> <xs:complexType name="KeyValuePair"> <xs:sequence> <xs:element name="key" type="xs:string" nillable="true" minOccurs="0"/> <xs:element name="value" type="xs:string" nillable="true" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="ArrayOfKeyValuePair"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="KeyValuePair" type="tns:KeyValuePair" nillable="true"/> </xs:sequence> </xs:complexType> </xs:schema> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:java/lang" xmlns:tns="urn:java/lang" elementFormDefault="qualified"> <xs:complexType name="ArrayOfString"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="String" type="xs:string" nillable="true"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="createInsourcingIncidentIn"> <wsdl:part name="externalKey" type="ns1:string"/> <wsdl:part name="title" type="ns1:string"/> <wsdl:part name="description" type="ns1:string"/> <wsdl:part name="impact" type="ns1:string"/> <wsdl:part name="urgency" type="ns1:string"/> <wsdl:part name="contact" type="ns1:string"/> <wsdl:part name="creatorGroup" type="ns1:string"/> <wsdl:part name="category1" type="ns1:string"/> <wsdl:part name="category2" type="ns1:string"/> <wsdl:part name="category3" type="ns1:string"/> <wsdl:part name="extReference" type="ns0:ArrayOfKeyValuePair"/> <wsdl:part name="attachments" type="ns0:ArrayOfAttachment"/> <wsdl:part name="additionalFields" type="ns0:ArrayOfKeyValuePair"/> <wsdl:part name="assignmentGroup" type="ns1:string"/> <wsdl:part name="assignmentSubGroup" type="ns1:string"/> <wsdl:part name="productId" type="ns1:string"/> <wsdl:part name="productName" type="ns1:string"/> <wsdl:part name="service" type="ns1:string"/> <wsdl:part name="customer" type="ns1:string"/> </wsdl:message> <wsdl:portType name="GDBIncidentWebServiceVi_Rpc"> <wsdl:operation name="createInsourcingIncident"> <wsdl:input message="tns:createInsourcingIncidentIn"/> <wsdl:output message="tns:createInsourcingIncidentOut"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>
Operation Definition
<wsdl:operation name="createInsourcingIncident"> <soap:operation soapAction=""/> <wsdl:input> <soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi" parts="externalKey title description impact urgency contact creatorGroup category1 category2 category3 extReference attachments additionalFields assignmentGroup assignmentSubGroup productId productName service customer "/> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="urn:GDBIncidentWebServiceVi"/> </wsdl:output> </wsdl:operation>
source share