function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Danny5Danny5 

A little stumped

Hi all, I'm new to web services.   So I ask forgiveness up front if I ask something not so intelligent.

 

I've been struggling to get a web service client constructed for a few days now.

 

I am using JAX-WS to generated my classes from the enterprise.wsdl that I downloaded from my developer site.

The first thing I don't understand is that the classes that get generated are different from the classes in the example JAX-WS quickstart on the salesforce site.  Meaning much of the example code doesn't work.

I suppose this is because the wsdl has changed some since the time that JAX-WS example was created. 

Is that the reason for the differences?

 

The login works fine, no problems there.  From reading after I get the login response I must:

1. Set the new end point so that all other requests will go the the url that login sent back.

2. Set the session id that was sent back from login into the SessionHeader

3. Set that Header back into the binded object (Soap in my case) (SoapBindingStub in the examples case)

 

# 1 I think I've got: (from a tutorial someone here pointed me to, tutorial is from partner wsdl, but seems to work)

 

       Map requestContext = ((BindingProvider)binding).getRequestContext();
                requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, lr.getResult().getServerUrl());

Different from the JAX-WS example code because I could not just call _setProperty on my binded object because it is not type SoapBindingStub but type Soap

 

#2 is easy enough

 

SessionHeader sh = new SessionHeader();       
sh.setSessionId(lr.getResult().getSessionId());

 # 3 has me stumped - in the JAX-WS example is it simply

    binding.setHeader(sforceURI, "SessionHeader", sh);

 Since my binded object is type Soap I have no setHeader method, in the tutorial that helped me earlier I found:

              JAXBContext jaxbContext;
                jaxbContext = JAXBContext.newInstance("sf");
                List<Header> headers = new ArrayList<Header>();
                headers.add(Headers.create((JAXBRIContext) jaxbContext, sh));
                WSBindingProvider wsBindingProvider = (WSBindingProvider) binding;
                wsBindingProvider.setOutboundHeaders(headers);

 But I cannot figure out what additonal jars I need to get this to complie.

 

So right now my code doesn't do #3 and when I do a query on the accounts table I get "Invalid Session ID found in SessionHeader: Illegal Session", which I assume is because I did not set the Header back into the binded object.

 

Any help on how to properly accomplish # 3 is greatly appreciated or anything else anyone can offer.

 

Thanks

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Danny5Danny5

Once I got all the needed jars together and added them as libraries in my project, all worked, I can now query.