在Drupal中发出SOAP请求?

时间:2012-02-13 03:38:05

标签: api drupal soap drupal-6 nusoap

我正在尝试使用以下格式实现与Drupal 6的SOAP调用:

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>

我是SOAP的新手,所有的Web文档都不适用于Drupal。此外,我必须在SOAP(而不是HTTP GET或POST)中进行此调用。

我如何在Drupal中进行SOAP调用?您能否使用上面的示例请求格式提供工作代码示例?

2 个答案:

答案 0 :(得分:5)

Drupal没有任何特定的soap功能 - 您可以使用内置的PHP客户端。应该有一个WSDL文件可用于生成soap客户端。像这样:

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

请参阅PHP的标准文档http://php.net/manual/en/book.soap.php

答案 1 :(得分:1)

老兄只需使用模块服务3,它包含您所需要的一切。你还要做一个(REST,XMLRPC,JSON,JSON-RPC,SOAP,AMF)调用,以便在drupal中实际执行这个操作你必须安装soap服务器到drupal ......

请点击此链接了解有关服务模块的更多信息。

http://drupal.org/project/services

这个drupal神奇模块之一