I have a web service developed using AXIS deployed on Weblogic 8.1
Another web application cotaining GUI deployed on Weblogic 10 tries to access this web service through code.
This piece of code to invoke the web service is written in Action Class present inside web application. (Struts is used in GUI based web app)
When the code tries to invoke web service I am getting following error.
(401)Unauthorized xxx
at org.apache.axis.transport.http.HTTPSender.readFrom Socket(HTTPSender.java:630)
at org.apache.axis.transport.http.HTTPSender.invoke(H TTPSender.java:128)
at org.apache.axis.strategies.InvocationStrategy.visi t(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain .java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.jav a:120)
at org.apache.axis.client.AxisClient.invoke(AxisClien t.java:180)
at org.apache.axis.client.Call.invokeEngine(Call.java :2564)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:1753)
at com.ebv.app.web.action.UCS77_1ProcessOfficialChang eSaveDetailsAction.invokeAx(UCS77_1ProcessOfficial ChangeSaveDetailsAction.java:243)
at com.ebv.app.web.action.UCS77_1ProcessOfficialChang eSaveDetailsAction.callUCS77_1ProcessOfficialChang eWebService(UCS77_1ProcessOfficialChangeSaveDetail sAction.java:173)
at com.ebv.app.web.action.UCS77_1ProcessOfficialChang eSaveDetailsAction.processAction(UCS77_1ProcessOff icialChangeSaveDetailsAction.java:133)
at com.ebv.framework.web.action.EBVAction.execute(EBV Action.java:106)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
The web service URL is as follows:
http://10.140.96.5:7808/services/ucs...7_1-v0001.soap
However
When I try to hit the webservice URL directly on browser login window appears where same username/password I provide which are passed in code to invoke the web service. I get the success page indicating that web service is invoked on hitting enter.
The method used in UCS77_1ProcessOfficialChangeSaveDetailsAction.java to invoke web service is as follows:
public String invokeAx
(
String xmlMessage,
String webServiceURL,
String webServiceOperation,
String username,
String password)
{
String xmlResponse = null;
Call webServiceCall = null;
InputStream input = new ByteArrayInputStream(xmlMessage.getBytes());
Service service = new Service();
try
{
webServiceCall = (Call) service.createCall();
SOAPEnvelope env = new SOAPEnvelope(input);
SOAPEnvelope resEnv = null;
webServiceCall.setTargetEndpointAddress(new URL(webServiceURL));
webServiceCall.setOperationName(new QName(webServiceOperation));
webServiceCall.setUsername(username);
webServiceCall.setPassword(password);
try
{
resEnv = webServiceCall.invoke(env);
}
catch (AxisFault e)
{
e.printStackTrace();
Message responseMessage = webServiceCall.getResponseMessage();
SOAPEnvelope soapXml = (SOAPEnvelope) responseMessage.getSOAPEnvelope();
xmlResponse = new String(soapXml.toString().getBytes(AppConstants.UT F8),AppConstants.UTF8);
}
if (xmlResponse == null)
{
xmlResponse = resEnv.toString();
}
}
catch (Exception e1)
{
e1.printStackTrace();
}
return xmlResponse;
}
Both the weblogic server reside on two different AIX machines.
Can anybody tell what's the problem while invoking web service through code?