za_switch has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks

How do you define a complex type in soap lite.

I have used this perl client side, to send a STRING to a php soap server that echo's the value back that I send to it without any problems...
use strict; package TESTso; use SOAP::Lite; # +trace => 'debug'; my $HOST = "http://138.215.248.216:8080/Soap/test.php"; my $NS = "ITest"; my $PHRASE = "hello"; my $soap = SOAP::Lite ->readable(1) ->uri($NS) ->proxy($HOST); my $som = $soap->MyResponse(SOAP::Data->name("What" => "$PHRASE")); print "The response from the server was:\n".$som->result."\n";
the only thing is how would i send a complex type like these two classes combined into one type nl. Questions_for_person to my php soap service.
Person  
  Name (String)
  Surname (String)
  Age (integer)
and
Question  
  Questions (Array of Strigs)
  Num_Questions (integer)
into a combined type:
Questions_for_person  
  a_Person (Person Type)
  a_QuestionList (Question Type)


Thanx for your help

2005-01-14 Edited by Arunbear: Changed title from 'SOAP::Lite', as per Monastery guidelines

Replies are listed 'Best First'.
Re: How to define a complex type with SOAP::Lite
by gellyfish (Monsignor) on Jan 14, 2005 at 13:07 UTC

    It really does depend on what schema your SOAP Server is expecting. Do you have a WSDL or schema or example XML instance for the expected messages?

    /J\

      Here is a simmalar example WSDL
      Notice the TEmployer and TDateType inside the TPerson complex type. By calling Addperson I would be able to able to save a person via soap. this works but how do I pass values like this in perl to my soap server using Soap lite?

      <?xml version="1.0"?><definitions name="Intf_person" targetNamespace=" +urn:Intf_person" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns: +soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:Intf_pers +on" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http +://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap. +org/wsdl/"> <types xmlns="http://schemas.xmlsoap.org/wsdl/"> <schema +xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Intf_pe +rson"> <complexType name="TPerson"> <all> <element name="Surname" typ +e="xsd:string" /> <element name="Fullname" type="xsd:string" /> <elem +ent name="DOB" type="tns:TDateType" /> <element name="Employer" type= +"tns:TEmployer" /> <element name="PostalAddress" type="tns:TPersonPos +talAddress" /> </all> </complexType> <complexType name="TPersonPostal +Address"> <all> <element name="ID" type="xsd:integer" /> <element nam +e="Line1" type="xsd:string" /> <element name="Line2" type="xsd:string +" /> <element name="Line3" type="xsd:string" /> <element name="Line4" + type="xsd:string" /> </all> </complexType> <complexType name="TEmplo +yer"> <all> <element name="Name" type="xsd:string" /> <element name=" +Tel" type="xsd:string" /> </all> </complexType> <complexType name="TD +ateType"> <all> <element name="Year" type="xsd:integer" /> <element n +ame="Month" type="xsd:integer" /> <element name="Day" type="xsd:integ +er" /> <element name="Hour" type="xsd:integer" /> <element name="Min" + type="xsd:integer" /> <element name="Sec" type="xsd:integer" /> </al +l> </complexType> </schema> </types> <portType name="Intf_personPort" +> <operation name="Addperson"> <input message="tns:AddpersonRequest" +/> <output message="tns:AddpersonResponse" /> </operation> </portType +> <binding name="Intf_personBinding" type="tns:Intf_personPort"> <soa +p:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http +" /> <operation name="Addperson"> <soap:operation soapAction="Intf_pe +rson#intf_person#Addperson" /> <input> <soap:body use="encoded" names +pace="Intf_person" encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" /> </input> <output> <soap:body use="encoded" namespace="Intf +_person" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> + </output> </operation> </binding> <service name="Intf_personService" +> <documentation /> <port name="Intf_personPort" binding="tns:Intf_pe +rsonBinding"> <soap:address location="http://138.215.248.216:8080/Soa +p/ntf_person.php" /> </port> </service> <message name="AddpersonReque +st"> <part name="Item" type="tns:Tperson" /> <part name="Systems" typ +e="tns:TSystemsList" /> </message> <message name="AddpersonResponse"> + <part name="ErrorReturned" type="xsd:string" /> </message> </definit +ions>

      20050114 Janitored by Corion: Added code tags around XML