使用PHP cURL到SOAP API返回XML

时间:2018-08-16 13:23:19

标签: php xml curl soap

已要求我从第三方公司获取用户列表。以前我对JSON,cURL和REST API都还可以,但是我真的很挣扎,请问有人可以帮忙吗?

为我提供了一个名为“ token”的参数和一个值,例如:“ AbCD1234XyZ”,我从中得到了一个示例XML结果,如下所示:

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://URLhere/server.php" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:getAllUsersResponse xmlns:ns1="urn:getAllUsers">
      <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:Person[2408]">
        <item xsi:type="tns:Person">
          <UserId xsi:type="xsd:string">114</UserId>
          <UserName xsi:type="xsd:string">Jeff</UserName>
          <UserEmail xsi:type="xsd:string">Jeff@company.com</UserEmail>
          <FirstName xsi:type="xsd:string">Jeff</FirstName>
          <LastName xsi:type="xsd:string">Doe</LastName>
          <RoleType xsi:type="xsd:string">Sales Rep</RoleType>
        </item>
      </return>
    </ns1:getAlljpUsersResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

为我提供了一个URL,例如:http://URLhere/server.php,该URL具有一个WSDL:http://URLhere/server.php?wsdl,并且我还具有以下内容:

Name: getAllUsers
Binding: serverBinding
Endpoint: http://URLhere/server.php
SoapAction: urn:getAllUsers#getAllUsers
Style: rpc
Input:
  use: encoded
  namespace: urn:getAllUsers
  encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
  message: getAllUsersRequest
  parts:
Output:
  use: encoded
  namespace: urn:getAllUsers
  encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
  message: getAllUsersResponse
  parts:
    return: tns:PersonArray
Namespace: urn:getAllUsers
Transport: http://schemas.xmlsoap.org/soap/http
Documentation: Return an array of people

有人可以帮忙吗?我已经搜索了几个小时,无法弄清楚。谢谢

0 个答案:

没有答案