Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a SOAP request in Drupal?

I am trying to implement a SOAP call with Drupal 6 with the following format:

POST /0_5/ClassService.asmx HTTP/1.1
Host: api.mindbodyonline.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://clients.mindbodyonline.com/api/0_5/AddClientsToClasses"

<?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:Body>
    <AddClientsToClasses xmlns="http://clients.mindbodyonline.com/api/0_5">
      <Request>
        <ClientIDs>
          <string>string</string>
          <string>string</string>
        </ClientIDs>
        <ClassIDs>
          <int>int</int>
          <int>int</int>
        </ClassIDs>
        <Test>boolean</Test>
        <RequirePayment>boolean</RequirePayment>
      </Request>
    </AddClientsToClasses>
  </soap:Body>
</soap:Envelope>

I am new to SOAP and all the web documentation doesn't work for Drupal. Also, I have to make this call in SOAP (not HTTP GET or POST).

How would I make a SOAP call in Drupal? Can you provide a working code example using the above example request format?

like image 473
AtomicCharles Avatar asked Oct 19 '25 13:10

AtomicCharles


1 Answers

Drupal doesnt have any specific soap functionality - you can use the built in PHP client. There should be a WSDL file you can use to generate your soap client. Something like this:

<?php
$client = new SoapClient("http://localhost/code/soap.wsdl");
$something =  $client->HelloWorld(array());
echo $something->HelloWorldResult;
die();

Refer to PHP's standard documentation http://php.net/manual/en/book.soap.php

like image 170
jakraska Avatar answered Oct 22 '25 08:10

jakraska



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!