如何使用Laravel和Soap 1.1连接Web服务

时间:2018-11-01 02:33:23

标签: php laravel web-services soap soap-client

您好,我需要连接到SOAP Web服务以从那里获取数据。 SOAP请求是:

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>
    <GetDS4Response xmlns="http://tempuri.org/WAPSWS/WAPSWS">
      <GetDS4Result>
        <xsd:schema>schema</xsd:schema>xml</GetDS4Result>
    </GetDS4Response>
  </soap:Body>
</soap:Envelope>

我尝试使用此代码,但刀片上没有任何内容

public function show()
    {
        $source = <<<SOURCE
<?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>
    <GetDS4 xmlns="http://tempuri.org/WAPSWS/WAPSWS">
      <CommandString>select top 10 * from applpendingremark</CommandString>
    </GetDS4>
  </soap:Body>
</soap:Envelope>
SOURCE;


$xml = simplexml_load_string($source);
$xml->registerXPathNamespace('tempuri', 'http://moaqs.com/MOAQSWS/WAPSWS.asmx?op=GetDS4');
$elements = $xml->xpath('//soap:Envelope/soap:Body/tempuri:GetDS4/tempuri:GetDS4');
$result = json_encode($elements, true);
print_r($result);



        return view('aa.aa',compact('result'));
    }

预先感谢

0 个答案:

没有答案