I have a java web service hosted in Apache Tomcat. Tomcat Server.xml file have an entry like this:
Connector port="8025" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"
But, the port 8443 (suppose to be ssl port) is commented out.
Using HTTPWatch, I noticed that server is redirecting the client request to http://sa-dev-sf.erp.net/testWSthree/service?wsdl. instead of https://.. and has following Header info in httpwatch: (Status-Line) HTTP/1.1 302 Found; Connection close Location sa-dev-sf.erp.net/testWSthree/service?wsdl
Here is my client test class. If I deploy the client in tomcat server and call the service I am getting error (See log below). Please note this is working fine from my local machine using Eclipse IDE
import a.Service; //from wsimport
import a.ServiceImplService; //from wsimport
public class Call {
public String callTest(){
ServiceImplService serviceImpl = new ServiceImplService();
Service s = serviceImpl.getServiceImplPort();
final BindingProvider getResultBP = (BindingProvider) s ;
getResultBP.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"https://sa-dev.erp.xxxx.net/testWSthree/service");
System.out.println(s.salaryUpgrade("sanjoy"));
}}
Here are the two classes generated by wsimport:
@WebService(name = "Service", targetNamespace = "http://a/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface Service {
/**
* @param name
* @return returns java.lang.String
*/
@WebMethod(operationName = "SalaryUpgrade")
@WebResult(partName = "return")
@Action(input = "http://a/Service/SalaryUpgradeRequest", output = "http://a/Service/SalaryUpgradeResponse")
public String salaryUpgrade(
@WebParam(name = "name", partName = "name")
String name);
}
and
@WebServiceClient(name = "ServiceImplService", targetNamespace = "http://a/", wsdlLocation =
"https://sa-dev.erp.xxxxx.net/testWSthree/service?wsdl")
public class ServiceImplService extends javax.xml.ws.Service
{
private final static URL SERVICEIMPLSERVICE_WSDL_LOCATION;
private final static WebServiceException SERVICEIMPLSERVICE_EXCEPTION;
private final static QName SERVICEIMPLSERVICE_QNAME = new QName("http://a/", "ServiceImplService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("https://sa-dev.erp.xxxxx.net/testWSthree/service?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
SERVICEIMPLSERVICE_WSDL_LOCATION = url;
SERVICEIMPLSERVICE_EXCEPTION = e;
}
public ServiceImplService() {
super(__getWsdlLocation(), SERVICEIMPLSERVICE_QNAME);
}
public ServiceImplService(WebServiceFeature... features) {
super(__getWsdlLocation(), SERVICEIMPLSERVICE_QNAME, features);
}
public ServiceImplService(URL wsdlLocation) {
super(wsdlLocation, SERVICEIMPLSERVICE_QNAME);
}
public ServiceImplService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, SERVICEIMPLSERVICE_QNAME, features);
}
public ServiceImplService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns Service
*/
@WebEndpoint(name = "ServiceImplPort")
public a.Service getServiceImplPort() {
return super.getPort(new QName("http://a/", "ServiceImplPort"), Service.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns Service
*/
@WebEndpoint(name = "ServiceImplPort")
public a.Service getServiceImplPort(WebServiceFeature... features) {
return super.getPort(new QName("http://a/", "ServiceImplPort"), Service.class, features);
}
private static URL __getWsdlLocation() {
if (SERVICEIMPLSERVICE_EXCEPTION!= null) {
throw SERVICEIMPLSERVICE_EXCEPTION;
}
return SERVICEIMPLSERVICE_WSDL_LOCATION;
}
}
This is working fine when I am calling the web service from Eclipse IDE. But if I deploy this client app in our tomcat server and call the service, I am getting the following error:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://sa-dev.erp.xxxxx.net/testWSthree/service?wsdl. It failed with:
Got sa-dev-sf.erp.umasscs.net while opening stream from https://sa-dev.erp.xxxxx.net /testWSthree/service?wsdl.
com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:173)
com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:155)
com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120)
com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:257)
com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:220)
com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:168)
com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:96)
javax.xml.ws.Service.<init>(Service.java:77)
a.ServiceImplService.<init>(ServiceImplService.java:41)
ws.callWS.Call.callTest(Call.java:26)
org.apache.jsp.index_jsp._jspService(index_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.io.IOException: Got sa-dev-sf.erp.umasscs.net while opening stream from https://sa- dev.erp.xxxxx.net/testWSthree/service?wsdl
com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:842)
com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:283)
I really appreciate any help on this issue. Thanks you.
web.xml
? – Eidson