Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer exception when getting SOAP response for a webservice

 
mast shaikh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
currently i am using apache SOAP-2.3.1.jar (web services deployed on weblogic 10.1 server)to test the web services .But i am getting following exception when testing the web service.

Exception in thread "main" java.lang.NullPointerException
at org.apache.soap.transport.TransportMessage.read(TransportMessage.java:206)
at org.apache.soap.util.net.HTTPUtils.post(HTTPUtils.java:382)
at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.j \
ava:309) at org.apache.soap.rpc.Call.invoke(Call.java:248)


When i debugged ,then came to know that server is not sending the Content type so its thorwing the null pointer exception.
is it a bug in the apache SOAP-2.3.1 jar .

Please let me know the how to resolve the isssue.

code i am using...

// create the transport and set parameters
SOAPHTTPConnection st = new SOAPHTTPConnection();
st.setMaintainSession(true);

// build the call.
Call call = new Call();
call.setSOAPTransport(st);
call.setTargetObjectURI("urn:TransferService");
call.setMethodName("getData");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);


Vector params = new Vector();

params.addElement(new Parameter("requestXml", String.class, downloadListXml, null));

call.setParams(params);
// invoke it
System.out.println("Invoking web service ");
Response resp;

SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
SOAPContext reqCtx = call.getSOAPContext();
Envelope callEnv = call.buildEnvelope();
StringWriter payloadSW = new StringWriter();
callEnv.marshall(payloadSW, smr, reqCtx);
reqCtx.setRootPart(payloadSW.toString(),
Constants.HEADERVAL_CONTENT_TYPE);
System.out.println("Invoking web service -->>>"+reqCtx.getContentType());

System.out.println("First Call");

st.setUserName(username);
st.setPassword(password);
System.out.println("Second Call");

resp = call.invoke(url,null); ---->>> here getting the isssue.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic