PHP Soap客户端

时间:2011-02-23 15:57:04

标签: php xml soap

HI,

我有这个xml我正在尝试为SOAP Client创建参数

<?xml version="1.0" encoding="utf-8" ?> 
<RequestGenerateInvoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="XML">
  <Type>enAdd</Type> 
  <Invoice>
      <InvoiceNumber>5</InvoiceNumber> 
      <InvoiceIDTxt>101</InvoiceIDTxt> 
      <AccountIDTxt>1001</AccountIDTxt> 
      <InvoiceDate>2011-02-21T15:04:42.8500736+02:00</InvoiceDate> 
      <Code>1</Code> 
      <Details>Some Details</Details> 
      <Quantity>1</Quantity> 
      <Amount>10</Amount> 
      <AmountDue>20</AmountDue> 
      <FromDate>2011-02-21T15:04:42.8490735+02:00</FromDate> 
      <ToDate>2011-02-21T15:04:42.8530738+02:00</ToDate> 
      <Months>7</Months> 
      <IsPrinted>false</IsPrinted> 
      <Paid>0</Paid> 
      <CardNumber>101</CardNumber> 
      <PrevAccBalance>100</PrevAccBalance> 
      <RealUsageAmount>80</RealUsageAmount> 
      <LocationID>0</LocationID> 
      <BatchNumber>1</BatchNumber> 
      <BatchText>Some Text</BatchText> 
  </Invoice>
  <RequestLocationID>0</RequestLocationID> 
  <RequestDateTime>0001-01-01T00:00:00</RequestDateTime> 
</RequestGenerateInvoice>

到目前为止,我的脚本是:

$client = new SoapClient("https://Some.?wsdl");
$client->MakeInvoice(array('Type'=>'enAdd', 
                           'Invoice'=> array('InvoiceNumber' => '101', 
                                             'InvoiceIDTxt' => '101', 
                                             'AccountIDTxt' => '2',......), 
                           'RequestLocationID'=>'2', 
                           'RequestDateTime'=>'0001-01-01T00:00:00'));

但是我一直没有得到服务器的响应

3 个答案:

答案 0 :(得分:1)

尝试使用SoapClient->_getLastRequest() SoapClient-> _getLastResponse()来了解幕后发生了什么。请注意,您需要在SoapClient构造函数中打开此功能:

$client = SoapClient("some.wsdl", array('trace' => 1));

答案 1 :(得分:0)

您需要Content-Type:text / xml

答案 2 :(得分:0)

我不相信这个XML是SOAP通信的一部分。没有SOAP信封和身体?!这似乎是一个ReST API。无论如何,你应该阅读API的文档。

如果您只对通过PHP生成打印的XML感兴趣,可以使用DOMSimpleXML