Tutorial :Web Service using SOAP WDSL with PHP



Question:

I've been trying to use a Web Service which has the WSDL file below. The bit I'm not sure about is what I am supposed to pass or do with the first part of it. It asks for a personaldetails object with a tns type to be passed to it but I don't understand what that means? The actual method I am trying to use is called PersonalDetails_Update and I am passing all of the relevant values to it but it keeps failing and I suspect it's to do with this personadetails object it asks for before it?

<s:element name="PersonalDetails_Update">  âˆ'  <s:complexType>  âˆ'  <s:sequence>  <s:element minOccurs="0" maxOccurs="1" name="personaldetails" type="tns:PersonalDetails"/>  </s:sequence>  </s:complexType>  </s:element>  âˆ'  <s:complexType name="PersonalDetails">  âˆ'  <s:sequence>  <s:element minOccurs="1" maxOccurs="1" name="ContactId" nillable="true" type="s:int"/>  <s:element minOccurs="1" maxOccurs="1" name="GenderId" type="s:int"/>  <s:element minOccurs="1" maxOccurs="1" name="EthnicityId" type="s:int"/>  <s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Initials" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Honours" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Surname" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Salutation" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Position" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Department" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="Organisation" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="AccessRequirements" type="s:string"/>  <s:element minOccurs="0" maxOccurs="1" name="DietaryNeeds" type="s:string"/>  <s:element minOccurs="1" maxOccurs="1" name="BirthDate" nillable="true" type="s:dateTime"/>  <s:element minOccurs="1" maxOccurs="1" name="IsNewContact" type="s:boolean"/>  <s:element minOccurs="1" maxOccurs="1" name="HoldingId" nillable="true" type="s:int"/>  <s:element minOccurs="1" maxOccurs="1" name="WebId" nillable="true" type="s:int"/>  <s:element minOccurs="1" maxOccurs="1" name="RecruitedId" type="s:int"/>  </s:sequence>  </s:complexType>  âˆ'  <s:element name="PersonalDetails_UpdateResponse">  âˆ'  <s:complexType>  âˆ'  <s:sequence>  <s:element minOccurs="1" maxOccurs="1" name="PersonalDetails_UpdateResult" type="s:int"/>  </s:sequence>  </s:complexType>  </s:element>  


Solution:1

The structure of the information to send is something like this:

<Envelope>    <Header/>    <Body>      <PersonalDetails_Update>        <personaldetails>          <ContactId>[some value]</ContactId>          <GenderId>[some value]</GenderId>          <EthnicityId>[some value]</EthnicityId>          <Title>[some value]</Title>          <Initials>[some value]</Initials>          <Honours>[some value]</Honours>          <FirstName>[some value]</FirstName>          <Surname>[some value]</Surname>          <Salutation>[some value]</Salutation>          <Position>[some value]</Position>          <Department>[some value]</Department>          <Organisation>[some value]</Organisation>          <AccessRequirements>[some value]</AccessRequirements>          <DietaryNeeds>[some value]</DietaryNeeds>          <BirthDate>[some value]</BirthDate>          <IsNewContact>[some value]</IsNewContact>          <HoldingId>[some value]</HoldingId>          <WebId>[some value]</WebId>          <RecruitedId>[some value]</RecruitedId>        </personaldetails>      </PersonalDetails_Update>    </Body>  </Envelope>  

PersonalDetails_Update is the service you'll be using personaldetails is the object that will hold the details PersonalDetails defines the details


Solution:2

Have a look at Zend_Soap and the native Soap extension. Both have information about how to write a Soap Client.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »