[SalesForce] Using Salesforce Partner API from community portal

I've created a custom button on the opportunity layout which calls out to an external java app. It passes the session id and the partner API URL. The external app then creates a SOAP binding (leveraging the partner wsdl downloaded from Setup). The first thing I do with the binding is call SoapBindingStub.getUserInfo().

My org has the Communities feature enabled to allow partner users to log in through community portals. When I click the custom button coming from a community portal, the above fails and I see "Caused by: (411)Length Required" in the stack. It works just fine if I click the button coming from salesforce (rather than a community portal).

Any ideas what's causing the RemoteException? I'm using the same user for both scenarios. Here's the full stack trace:

Caused by: (411)Length Required at 
org.apache.axis.transport.http.CommonsHTTPSender.invoke(CommonsHTTPSender.java:218) at 
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at 
org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at 
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at 
org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at 
org.apache.axis.client.Call.invokeEngine(Call.java:2784) at 
org.apache.axis.client.Call.invoke(Call.java:2767) at 
org.apache.axis.client.Call.invoke(Call.java:2443) at 
org.apache.axis.client.Call.invoke(Call.java:2366) at 
org.apache.axis.client.Call.invoke(Call.java:1812) at 
com.sforce.soap.partner.SoapBindingStub.getUserInfo(SoapBindingStub.java:3994)

I'm wondering if the URL is the cause. Is there some setting/permission in communities that needs to be set in order to do this? Here are the URLS observed:

https://myCommunityDomainName.force.com/myCommunityName/services/Soap/u/28.0/00Di0000000eG2r -does not work

https://na15.salesforce.com/services/Soap/u/28.0/00Di0000000eG2r -works

Best Answer

Found an answer for this.

I used SOAP UI to try making these calls, and I got a more helpful error message: "API access is disabled for Communities". From there I was able to find a blog post with some details.

Apparently, when coming from a Community portal, the API.Parner_Server_URL should not be used to make API calls back to Salesforce (what?!). Salesforce support says to use the endpoint that would result from a standard salesforce user clicking the link (na15.salesforce.com/... as seen above, for example). They claim it is working as designed, which makes me wonder what the heck API.Parner_Server_URL is any good for when coming though a community portal.

Here's the blog post for reference: http://boards.developerforce.com/t5/APIs-and-Integration/API-Access-Disabled-for-Communities/td-p/644035

EDIT: See Dana's answer below; according to the author, support for this has been added as of Summer '15.

Related Topic