2010-02-16 8 views
0

Je dois créer un client PHP SOAP qui envoie des leads, mais je n'ai jamais travaillé avec SOAP auparavant, et mon XML n'est pas génial, voici le code que j'ai réussi à écrire jusqu'à présent. . .Aide client SOAP PHP!

<?php 

    try { 

     $client = new SoapClient(null, array(
     'location' => "https://wwa.website.co.za/CallmasterTes/LeadService.asmx", 
     'uri'  => "urn:Website:Callmaster:InTuch/CreateLead", 
     'login'  => "username", 
     'password' => "password" 
     )); 

      $sysName = ' '; 
      $clientCode = ' '; 
      $expTimestamp = ' '; 
      $schedTimestamp = ' '; 

     $client->CreateLead("ExternalLead", 
         new SoapParam($sysName, "BusinessSystemName"), 
         new SoapParam($clientCode, "BusinessSystemClientCode"), 
         new SoapParam($_POST['Title'], "Title"), 
         new SoapParam($_POST['FirstName'], "FirstName"), 
         new SoapParam($_POST['Surname'], "Surname"), 
         new SoapParam($_POST['IdNumber'], "IdNumber"), 
         new SoapParam($_POST['Gender'], "Gender"), 
         new SoapParam($_POST['DateOfBirth'], "DateOfBirth"), 
         new SoapParam($_POST['Language'], "Language"), 
         new SoapParam($_POST['EmailAddress'], "EmailAddress"), 
         new SoapParam($_POST['HomeTelNumber'], "HomeTelNumber"), 
         new SoapParam($_POST['BusinessTelNumber'], "BusinessTelNumber"), 
         new SoapParam($_POST['MobileTelNumber'], "MobileTelNumber"), 
         new SoapParam($_POST['OtherTelNumber'], "OtherTelNumber"), 
         new SoapParam($_POST['PreferredTelNumberCode'], "PreferredTelNumberCode"), 
         new SoapParam($_POST['CampaignName'], "CampaignName"), 
         new SoapParam($_POST['ProductName'], "ProductName"), 
         new SoapParam($_POST['Comments'], "Comments"), 
              new SoapParam($expTimestamp, "ExpiryTimestamp"), 
              new SoapParam($schedTimestamp, "ScheduledTimestamp"), 
         ); 

    } 

    catch (SoapFault $fault) { 
     trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR); 
    } 

?> 

Ce qui suit est une demande d'échantillon SOAP 1.2 et la réponse que m'a donné par les développeurs sur le côté serveur des choses.

POST /CallmasterTest/LeadService.asmx HTTP/1.1 
Host: wwa.website.co.za 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
    <CreateLead xmlns="urn:Website:Callmaster:InTuch"> 
     <Lead> 
     <BusinessSystemName>string</BusinessSystemName> 
     <BusinessSystemClientCode>int</BusinessSystemClientCode> 
     <Title>Mr or Ms or Mrs or Miss...etc</Title> 
     <FirstName>string</FirstName> 
     <Surname>string</Surname> 
     <IdNumber>string</IdNumber> 
     <Gender>Male or Female</Gender> 
     <DateOfBirth>date</DateOfBirth> 
     <Language>string</Language> 
     <EmailAddress>string</EmailAddress> 
     <HomeTelNumber>string</HomeTelNumber> 
     <BusinessTelNumber>string</BusinessTelNumber> 
     <MobileTelNumber>string</MobileTelNumber> 
     <OtherTelNumber>string</OtherTelNumber> 
     <PreferredTelNumberCode>Business or Home or Mobile or Other</PreferredTelNumberCode> 
     <CampaignName>string</CampaignName> 
     <ProductName>string</ProductName> 
     <Comments>string</Comments> 
     <ExpiryTimestamp>dateTime</ExpiryTimestamp> 
     <ScheduledTimestamp>dateTime</ScheduledTimestamp> 
     </Lead> 
    </CreateLead> 
    </soap12:Body> 
</soap12:Envelope> 

La réponse:

HTTP/1.1 200 OK 
Content-Type: application/soap+xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
    <CreateLeadResponse xmlns="urn:Website:Callmaster:InTuch"> 
     <CreateLeadResult> 
     <Success>boolean</Success> 
     <StatusMessage>string</StatusMessage> 
     <LeadGuid>guid</LeadGuid> 
     <Errors> 
      <LeadError ErrorLevel="Information or Warning or Error"> 
      <Message>string</Message> 
      <Field>string</Field> 
      </LeadError> 
      <LeadError ErrorLevel="Information or Warning or Error"> 
      <Message>string</Message> 
      <Field>string</Field> 
      </LeadError> 
     </Errors> 
     </CreateLeadResult> 
    </CreateLeadResponse> 
    </soap12:Body> 
</soap12:Envelope> 

J'ai vraiment tout essayé, et googlé en haut des cieux, mais je ne peux pas le faire fonctionner, je suis sûr que c'est probablement quelque chose de petit que je Je manque, j'apprécierais vraiment l'aide, merci!

Répondre

1

Je ne sais pas s'il s'agit d'une erreur de copier/coller ou non, mais tous les _POST s doivent être $_POST s dans votre premier exemple de code.

+0

Oups, seulement vu que maintenant, ce doit être une erreur C/P. Merci de l'avoir signalé. – Odyss3us

+0

Aussi, il semble que ''location' =>" https://www.website.co.za/CallmasterTes/LeadService.asmx "' devrait être ''location' =>" https://wwa.website.co .za/CallmasterTest/LeadService.asmx "' – emmychan

+0

Je vais y jeter un coup d'oeil, mais le code semble-t-il fonctionner? – Odyss3us