Confluence soap api定义了两个同名但参数不同的方法:
- Page getPage(String token, long pageId) - 返回单个 Page(根据文档,第二个参数是 String,但在 WSDL 中它很长)
- Page getPage(String token, String spaceKey, String pageTitle) - 返回单个 Page
我需要使用 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错误报告和另一个,以及Atlassian 论坛上的讨论,但没有一个对我有帮助。
到目前为止,最好的建议是通过删除其他 getPage 定义并将其保存在本地某处来调整 WSDL。