在PHP中构建对SoapClient的调用

时间:2011-05-04 05:14:21

标签: php soap

我是SOAP新手并试图弄清楚如何构建对SOAP服务器的调用。以下是我想要得到的定义:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prov="http://bridgewatersystems.com/xpc/subscribermetering/service/provisioning/">
   <soapenv:Header/>
       <soapenv:Body>
          <prov:GetMeteringStateRequest>
              <subscriber subscriber-id="USERID" />
          </prov:GetMeteringStateRequest>
       </soapenv:Body>
    </soapenv:Envelope>

这是我用来测试的PHP(当然不是用的):

$user_id = "REALIDHERE";

$parameters->subscriber_id = $user_id;
$parameters->MIN = "test";
$parameters->partition_key = "test";

try {
  $client = new SoapClient("http://SOAPIP:32010/soap/services/SubscriberMeteringProvisionAPI.wsdl");

  echo "trying...\n";
  print( $client->GetMeteringState( new SoapParam("subscriber", $parameters ) ) );
} catch (SoapFault $e) {
  //var_dump($e);
}

任何有关调用GetMeteringState()的工作都会很棒。

感谢。

1 个答案:

答案 0 :(得分:0)

我建议您查看请求生成的XML。这很好解释here,但这是一个例子:

// prepare SoapClient
$client = new SoapClient("http://.../SubscriberMeteringProvisionAPI.wsdl");
print( $client->GetMeteringState( new SoapParam("subscriber", $parameters ) ) );

// output the XML request
echo "<pre>".$client->__getLastRequest()."</pre>";