You need to sign in to do that
Don't have an account?

JAX-WS / webservice class / Injecting Session ID.
Hello all.
I'm experiementing with creating my own webservice classes on force.com.
I have created my own Apex class and marked it as a web service.
I've generated the WSDL and created a client in Netbeans using its JAX-WS tooling.
I have attempted to run this web service and run into the 'missing Session ID' problem.
To avoid this, I have generated the Partner WSDL and created additional client stubs for the Partner client, I've then executed the login method on the Partner ID and obtained a valid session Id string.
My issue is now a JAX-WS issue, how do I inject this session ID into the client I use to assess my own webservice class? I can find no method / object to do this. There is a 'SessionHeader' class in my custom client which I can call a 'setSessionId()' method on, but I can't figure out how to inject my SessionHeader into my port/service.
I'm not a WS guru... so is there something I'm missing?
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication3; import enterprise.InvalidIdFault_Exception; import enterprise.LoginFault_Exception; import enterprise.LoginResult; import enterprise.UnexpectedErrorFault_Exception; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.xml.ws.WebServiceFeature; import javax.xml.ws.handler.Handler; import javax.xml.ws.handler.HandlerResolver; import javax.xml.ws.handler.PortInfo; /** * * @author sherod */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { try { LoginResult r = login("xxxx", "xxxx"); myMethod(r.getSessionId(),null); } catch (InvalidIdFault_Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (UnexpectedErrorFault_Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (LoginFault_Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } private static LoginResult login(java.lang.String username, java.lang.String password) throws InvalidIdFault_Exception, UnexpectedErrorFault_Exception, LoginFault_Exception { enterprise.SforceService service = new enterprise.SforceService(); enterprise.Soap port = service.getSoap(); return port.login(username, password); } private static TestData myMethod(String sessId, javaapplication3.TestData t) { javaapplication3.MyWebServiceService service = new javaapplication3.MyWebServiceService(); javaapplication3.SessionHeader sh = new javaapplication3.SessionHeader(); sh.setSessionId(sessId); System.out.println(sessId); //session ID output, but where to I send 'sh'? javaapplication3.MyWebServicePortType port = service.getMyWebService(); return port.myMethod(t); } }
Salesforce WSC is high performance java client implementation, that works on a streaming parser. I suggest you using that instead. Here is the link to the WSC page : http://code.google.com/p/sfdc-wsc/
Their is a WSC wrapper project, called Tolerado available. That makes your life easy, by setting all these sessionid/server urls. Check this out here : http://code.google.com/p/tolerado-sfdc-wsc-apis/
In case you are in mood to develop something for research on Jax-WS then, the above links are of no use for u. In that case I would suggest, that for every SFDC webservice call you need to pass sessionid + server url in headers. So you can see how Apache Axis or WSC does that.
The series of blog posts starting with http://eng.genius.com/blog/2009/05/23/salesforcecom-partner-soap-api-jax-ws-tutorial-part-1/ show how to use JAX-WS with salesforce.