#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    India
    Posts
    2
    Rep Power
    0

    Lightbulb How to create simple SOAP request using PHP?


    Hello,

    I tried to create a SOAP request but could not succeed.
    SOAP WADL url is http://www.mobipost.com.au/httpapi/Messaging.asmx?WSDL

    AND request should be like:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <AuthenticationHeader xmlns="http://messaging.mobipostapi.thirdscreen.com.au/">
          <UserName>SAMPLE_USER</UserName>
          <Password>SAMPLE_PASS</Password>
        </AuthenticationHeader>
      </soap:Header>
      <soap:Body>
        <SendSMSToContacts xmlns="http://messaging.mobipostapi.thirdscreen.com.au/">
          <oSMS>
            <MessageText>THIS IS MESSAGE</MessageText>
          </oSMS>
          <ContactIDs>
            <int>123456789</int>
            <int>987654321</int>
          </ContactIDs>
        </SendSMSToContacts>
      </soap:Body>
    </soap:Envelope>

    I tried:

    Code:
    $url = 'http://www.mobipost.com.au/httpapi/Messaging.asmx?WSDL';
    $client = new SoapClient($url);
    $result = $client->AuthenticationHeader(array('UserName' => 'SAMPLE_USER','Password' => 'SAMPLE_PASS'));
    $result = $client->SendSMSToContacts(array('MessageText' => 'THIS IS MESSAGE'));
    $result = $client->ContactIDs(array('123456789', '987654321'));
    But it shows Error:
    Code:
    Fatal error: Uncaught SoapFault exception: [Client] Function ("AuthenticationHeader") is not a valid method for this service in D:\xampp\htdocs\globalmobile\send_message_v2.php:26 Stack trace: #0 D:\xampp\htdocs\globalmobile\send_message_v2.php(26): SoapClient->__call('AuthenticationH...', Array) #1 D:\xampp\htdocs\globalmobile\send_message_v2.php(26): SoapClient->AuthenticationHeader(Array) #2 {main} thrown in D:\xampp\htdocs\globalmobile\send_message_v2.php on line 26

    Can you please help me to create valid SOAP request to communicate with WSDL server?


    Thank you in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,868
    Rep Power
    368
    if you look at the WDSL you will see AuthenticationHeader is not a method! the error is very clear!

    use http://www.soapclient.com/soaptest.html

    or download soap ui. (google it!)

    and you will see what method are available!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    India
    Posts
    2
    Rep Power
    0
    Hello paulh1983,

    I am beginner with SOAP. Can you please help me how to authenticate header and send body parameters?

    Thanks in bunch.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,868
    Rep Power
    368
    the document will tell you, sometimes even give you examples.. just go through the document. google it and you might also find tutorials/examples..

IMN logo majestic logo threadwatch logo seochat tools logo