How to call an overloaded SOAP method using PHP SoapClient?

Confluence soap api defines two methods with the same name but with different parameters:

  • GetPage page (String token, long pageId) - returns one page (according to the documentation, the second parameter is String, but in WSDL it is long)
  • GetPage page (String token, String spaceKey, String pageTitle) - returns one page

I will need to call a method with two parameters using PHP SoapClient. In WSDL mode, SoapClient insists on using a three-parameter. In a mode other than WSDL, I managed to make a call with two parameters, but I cannot make the type of the second parameter long. How can I get SoapClient to call getPage with two parameters with the correct types?

Here is what I have done so far:

Using SoapClient in WSDL Mode ...

$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); 

... calls the request for the three-parameter method (only for the shown body) ...

 <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> 

... which causes the error:

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

A page with this identifier exists, and I am allowed to see it, which I can confirm by making the correct request using SoapUI.

Using SoapClient is a non-WSDL mode ...

 $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); 

... creates a query for a two-parameter method with the wrong type for the second parameter. When $ confluence_article_id is a string, the query ...

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

... which returns the same error as above:

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

When $ confluence_article_id is an integer, the request ...

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

... which returns a different kind of error:

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

If I take the request, change int to long and try it with SoapUI, it will work fine.

I also tried calling it using __soapCall, but the results are similar:

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

There is a related PHP bug report and another discussion on the Atlassian forums , but none of them helped me.

So far, the best suggestion is to configure WSDL by removing another getPage definition and saving it locally somewhere.

+4
source share
1 answer

If I remember correctly, you can call the function using an associative array instead of ex:

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

Not verified, standard warnings apply

0
source

All Articles