views:

562

answers:

1

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

  • Page getPage(String token, long pageId) - returns a single Page (according to the documentation the second parameter is String, but in WSDL it is long)
  • Page getPage(String token, String spaceKey, String pageTitle) - returns a single Page

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

Here's what I've 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);

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

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

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

The page with that ID does exist and I am allowed to see it, which I can confirm by making the correct kind of request with SoapUI.

Using SoapClient is 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);

...produces a request for the two-parameter method with incorrect type for the second parameter. When $confluence_article_id is string, the request is...

<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 fault 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 integer, the request is...

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

<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 works just fine.

I have also tried to call 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 one, and discussion on Atlassian forums, but none of them helped me.

So far the best suggestion has been to tweak the WSDL by removing the other getPage definition and saving it locally somewhere.

A: 

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

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

Not tested, standard warnings apply

Kristoffer S Hansen
Thanks for the answer, but I think I tried that too without success (I'm not involved with that project any more so I cannot verify). I ended up using a tweaked version of WSDL where I had removed the other getPage definition. Accepting your answer anyway :)
jarnoan