2013-07-24 79 views
0

我需要一些帮助才能开始使用SOAP API。我必须为客户网站的空缺部分实施API。使用PHP的SOAP请求

我需要通过PHP实现SOAP API。 我需要问一个WSDL文件吗?或者是包含的文档足以调用API

的文档描述如下:

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

参数

& = DeveloperKey为

- Required 

&客户ID =

- 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 

& EducationLevel =

- 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 

样本输出 http://piratepad.net/soap-xml-sample-output

+0

您正在连接到SOAP API(即编写客户端应用程序),还是自己实现SOAP API(即编写服务器应用程序)? –

+0

我正在连接到API – TheAnchorsmith

回答

0

我建议使用Zend_Soap_Client,用于连接到SOAP API的一个通俗图书馆。

这是一个漂亮的decent tutorial,它解释了如何使用库。如果您使用composer进行依赖性管理(强烈建议),则可以绕过安装说明并仅安装包装zendframework/zend-soap

的基础步骤是:

实例化一个新Zend_Soap_Client,传递WSDL所以客户端,以便它知道方法+ API的参数。

$this->soapClient = new Zend_Soap_Client(
    'http://url.to.your.api.com?WSDL' 
); 

调用一个可用的方法,传递任何必需的参数,然后获取result属性。因此,对于GetAllJob,其很可能是:

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

一旦你得到一些数据回来,看向SOAP客户端集成到您的广泛应用。

+0

感谢您的回复。我会打电话给API供应商以获取wsdl位置,因为在API文档中没有提及它。我必须将它实现到Wordpress环境中,所以我认为我会坚持使用PHP中的标准SoapClient类。如果我有解决方案,我会更新这篇文章。 – TheAnchorsmith

+0

我已经从供应商处获得了wsdl文件。 他们忘了将它实现到api文档 – TheAnchorsmith

0

感谢你的一切,我已经实现了从PHP的SoapClient和__soapcall方法,现在它的工作。

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