2010-01-18 114 views
4

Confluence soap api定义了两种方法具有相同的名字,但不同的参数:如何使用PHP SoapClient调用重载的SOAP方法?

  • 页GETPAGE(字符串令牌,长PAGEID) - 返回单个页(根据文档的第二个参数是字符串,但在WSDL它是长)
  • 页GETPAGE(字符串令牌,广州雄兵字符串,字符串PAGETITLE) - 返回一个页面

我需要调用的方法用PHP SoapClient的两个参数。在WSDL模式下,SoapClient坚持使用三参数。在非WSDL模式下,我设法使用两个参数进行调用,但我无法使第二个参数的类型变长。如何让SoapClient使用两个正确类型的参数调用getPage?

这是我到目前为止已经完成:

在WSDL模式下使用SoapClient的...

$soapClient = new SoapClient("http://xxx/confluence/rpc/soap-axis/confluenceservice-v1?wsdl", array("trace" => TRUE)); 
$token = $soapClient->login(CONFLUENCE_USERNAME, CONFLUENCE_PASSWORD); 
$page = $soapClient->getPage($token, $confluence_article_id); 

...产生三个参数方法(只显示机构)的请求。 ..

<SOAP-ENV:Body><ns1:getPage><in0 xsi:type="xsd:string">dkjLIx00Ap</in0><in1 xsi:type="xsd:string">24445207</in1><in2 xsi:nil="true"/></ns1:getPage></SOAP-ENV:Body> 

...这会导致故障:

<faultstring>com.atlassian.confluence.rpc.RemoteException: You're not allowed to view that page, or it does not exist.</faultstring> 

带有该ID的页面确实存在,我可以看到它,我可以通过使用SoapUI进行正确的请求来确认。

使用SoapClient的是非WSDL模式...

$soapClient = new SoapClient(null, array(
    "location" => "http://xxx/confluence/rpc/soap-axis/confluenceservice-v1", 
    "uri" => "http://soap.rpc.confluence.atlassian.com", 
    "trace" => TRUE)); 
$token = $soapClient->login(CONFLUENCE_USERNAME, CONFLUENCE_PASSWORD); 
$page = $soapClient->getPage($token, $confluence_article_id); 

...产生用于双参数方法使用不正确的类型为第二个参数的请求。当$ confluence_article_id是字符串,请求...

<SOAP-ENV:Body><ns1:getPage><param0 xsi:type="xsd:string">8Or94ZLqe7</param0><param1 xsi:type="xsd:string">24445207</param1></ns1:getPage></SOAP-ENV:Body> 

...返回上述同样的故障:

<faultstring>com.atlassian.confluence.rpc.RemoteException: You're not allowed to view that page, or it does not exist.</faultstring> 

当$ confluence_article_id是整数,请求...

<SOAP-ENV:Body><ns1:getPage><param0 xsi:type="xsd:string">y0kF4z0m9L</param0><param1 xsi:type="xsd:int">24445207</param1></ns1:getPage></SOAP-ENV:Body> 

...它返回一个不同类型的故障:

<faultstring>org.xml.sax.SAXException: Bad types (int -> class java.lang.String)</faultstring> 

如果我接受请求,将int更改为long并使用SoapUI进行尝试,它工作得很好。

我也曾尝试使用__soapCall称呼它,但结果是相似的:

$page = $soapClient -> __soapCall('getPage', array('in0'=>$token,'in1'=>$confluence_article_id)); 

有一个相关的PHP bug reportanother one,并且discussion on Atlassian forums,但没有人帮助我。

到目前为止,最好的建议是通过删除其他getPage定义并将其保存在本地某处来调整WSDL。

回答

0

如果我没记错的话,你可以使用关联数组,而不是前调用该函数:

//Page getPage(String token, String spaceKey, String pageTitle) 
$soapClient->getPage(array("token" => $token,"spaceKey" => $spaceKey,"pageTitle" => $pageTitle)); 

没有测试,标准的警告适用

+0

感谢您的回答,但我想我试过,也没有成功(我不再参与该项目,所以我无法验证)。我最终使用了一个已经删除了另一个getPage定义的WSDL的调整版本。无论如何,接受你的答案:) – jarnoan 2010-03-08 11:13:21