SOAP PHP请求

时间:2016-06-13 20:41:59

标签: php soap

我正在尝试将此示例请求转换为PHP SOAP函数。这就是我所需要的肥皂服务器的支持。我几乎没有任何SOAP经验,我无法弄清楚如何在PHP中构建它。

<CreateCustomerRequest xmlns="http://schemas.datacontract.org/2004/07/BillingTree.ApiService.Contract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <MerchantCredentials>
        <CertId></CertId>
        <Password></Password>
        <UserName></UserName>
        <Zid></Zid>
    </MerchantCredentials>
    <Customer>
        <Address>
            <AddressLine1></AddressLine1>
            <AddressLine2 i:nil="true"/>
            <AddressLine3 i:nil="true"/>
            <City>Los Angeles</City>
            <Country>USA</Country>
            <Province i:nil="true"/>
            <State>CA</State>
            <ZipCode>85284</ZipCode>
        </Address>
        <Department></Department>
        <Email></Email>
        <Fax i:nil="true"/>
        <FirstName></FirstName>
        <Id></Id>
        <LastName></LastName>
        <Phone></Phone>
        <Status>Active</Status>
        <Title></Title>
    </Customer>
</CreateCustomerRequest>

2 个答案:

答案 0 :(得分:1)

如果您是SOAP的新手,那么您应该尝试使用WSDL到PHP生成器来简化SOAP请求的构建。您可以尝试项目PackageGenerator,这样您最终将获得SOAP Web服务的完整PHP SDK和教程文件作为入门指南。

答案 1 :(得分:0)

< ? php
// $client = new SoapClient('http://localhost/php/soap/math.wsdl');
$client = new SoapClient("http://localhost/php/soap/soap_server.php? WSDL");
try{
  $result = $client->div(8, 2);
  print "The answer is: $result";
}catch(SoapFault $e){
  print "Sorry an error was caught executing your request: {$e->getMessage()}";
}
?>

你可以像这样使用一个非常基本的例子