PHP中给定的请求和响应结构的SOAP响应

时间:2014-01-22 08:30:48

标签: php soap

由于我对SOAP很陌生,我真的需要一些帮助才能开始。我得到了这个结构:

请求:

    POST /NumbriParing/NumbriParing.asmx HTTP/1.1
Host: nba.tja.ee
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://nba.sa.ee/NumriomanikuParing"

<?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>
    <NumriomanikuParing xmlns="http://nba.sa.ee/">
      <number>long</number>
    </NumriomanikuParing>
  </soap:Body>
</soap:Envelope>

响应:

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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>
    <NumriomanikuParingResponse xmlns="http://nba.sa.ee/">
      <NumriomanikuParingResult>
        <Number>long</Number>
        <OmanikuRegNumber>string</OmanikuRegNumber>
        <Omanik>string</Omanik>
        <VastusKood>NumberLeitud or NumbritEiLeitud</VastusKood>
      </NumriomanikuParingResult>
    </NumriomanikuParingResponse>
  </soap:Body>
</soap:Envelope>

我需要用数字变量替换请求中的“long”占位符以获取该数字的请求。 asmx位于https://nba.tja.ee/NumbriParing/NumbriParing.asmx 如何使用php完成?

祝你好运, 马尔蒂阿赫

1 个答案:

答案 0 :(得分:0)

使用您需要的服务的SoapClient和WSDL。 类似的东西:

try {
    $client = new SoapClient('https://nba.tja.ee/NumbriParing/NumbriParing.asmx?WSDL');
    $param = new stdClass();
    $param->number = 123;
    $result = $client->NumriomanikuParing($param);

    var_dump($result);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
相关问题