SalesForce: 调用自定义API时应如何处理session问题

你用APEX写了一个API (Web Service), 然后用wsc生成stub,然后用其中的connector生成soapConnection,最后调用你的API。结果你遇到这样的错误:

  “INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session”

这是因为connection生成soapConnection时并不会去登录,也就不会生成session id. 

解决办法是先生成Enterprise Connection,把这个Connection里的session-id取出来,再塞到自定义API对应的soapConnection中。

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.