This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes Calling webservice: works from standalone app but not from weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Calling webservice: works from standalone app but not from weblogic" Watch "Calling webservice: works from standalone app but not from weblogic" New topic
Author

Calling webservice: works from standalone app but not from weblogic

Simone Battagliero
Greenhorn

Joined: Jun 14, 2011
Posts: 1
Hi,
I'm calling a SOAP 1.1 webservice which use basic HTTP authentication. All works well in a standalone class, but if I put the same code into a web application, for example in an Action class, it doesn't work. I receive a 500 response code, and an empty body. Can you help me?
My code looks like this, using the Apache Commons libraries:

...
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("<webservice_server>", 80),
new UsernamePasswordCredentials("<username>", "<password>")
);
PostMethod post = new PostMethod("<webservice_url>");
post.setRequestHeader("SOAPAction", "<webservice_url>#<method>");
post.setRequestBody(new StringBufferInputStream(input)); //input previously defined
post.setDoAuthentication(true);
try {
int status = client.executeMethod( post );
String body = post.getResponseBodyAsString();
if(status == 200){
return body;
}else{
throw new Exception("status: " + status + " body: " + body);
}
} finally {
post.releaseConnection();
}

Thank you

Simone
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling webservice: works from standalone app but not from weblogic
 
Similar Threads
Sending big file using web service
Best Practice to send a request to 2 destinations?
Postmethod
Using PostMethod to post from a servlet without capturing the response body
Communication between Two web application Problem.