用PHP实现SOAP请求

用PHP实现SOAP请求,php,soap,wsdl,Php,Soap,Wsdl,我需要一些帮助来开始使用SOAP API。我必须为客户网站的空缺部分实现API 我需要通过PHP实现SOAP API。 我需要请求WSDL文件吗?或者所包含的文档是否足以调用api 本文档描述了以下内容: GetAllJob 返回搜索结果列表。仅获取请求 参数 &DeveloperKey= - Required - Required, numeric only - Optional, string, must be URL encoded - Can accept a sin

我需要一些帮助来开始使用SOAP API。我必须为客户网站的空缺部分实现API

我需要通过PHP实现SOAP API。 我需要请求WSDL文件吗?或者所包含的文档是否足以调用api

本文档描述了以下内容:

GetAllJob
返回搜索结果列表。仅获取请求

参数

&DeveloperKey=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
&CustomerId=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
&Keywords=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
&Location=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
&Category=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
&EducationLevel=

  - Required
  - Required, numeric only
  - Optional, string, must be URL encoded
  - Can accept a single value, or a comma-separated list of values
  - Optional, string, must be URL encoded
  - Can accept a single city name, a postal code or a comma-separated city
  - Optional, numeric (Category code)
  - Can accept a single value only.
  - If the given value do not match any of category codes, this parameter is ignored. We do not attempt any partial matching
  - Reference the Categories service for a complete list of valid category names and codes
  - Optional, numeric (Education level code)
  - Can accept a single value only.
  - Reference the Education level service for a complete list of valid education level names and codes
样本输出

我建议使用Zend_Soap_客户端,这是一个连接到Soap API的流行库

这是一个解释如何使用该库的程序。如果您使用for dependency management(强烈推荐),则可以绕过安装说明,只需安装包zendframework/zend soap

基本步骤是:

实例化一个新的
Zend_Soap_客户端
,传递WSDL以便客户端知道API的方法和参数

$this->soapClient = new Zend_Soap_Client(
    'http://url.to.your.api.com?WSDL'
);
调用您可用的方法,传递任何必需的参数,然后获取result属性。因此,对于GetAllJob,它可能是:

$allJobs = $this
    ->soapClient
    ->GetAllJob($parameters)
    ->GetAllJobResult
;

一旦您恢复了一些数据,请尝试将soap客户端集成到更广泛的应用程序中。

感谢您所做的一切,我已经从php中实现了SoapClient和uu soapcall方法,现在它开始工作了


问题是没有wdsl文件。我已经找到了wdsl的位置,现在它正在工作。

您是连接到SOAP API(即编写客户端应用程序)还是自己实现SOAP API(即编写服务器应用程序)?我正在连接到API谢谢您的回复。我将调用API供应商获取wsdl位置,因为在API文档中没有对它的引用。我必须在Wordpress环境中实现它,所以我认为我将坚持使用PHP中的标准SoapClient类。如果我有解决方案,我会更新这篇文章。我从供应商那里得到了wsdl文件。他们忘了在api文档中实现它