I have a webservice in Java 1.6 that extends javax.xml.ws.Service. The WSDL URL is located at an HTTPS endpoint and I am behind a corporate proxy (NTLM I believe). I have the proxy host, port, username, and password. I have verified that I can access the WSDL using curl if I specify the proxy in my .curlrc file. When the constructor is called it will eventually timeout with the error:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.blah.com/myservice.asmx?wsdl. It failed with:
Connection timed out.
The call that fails is:
public MyService_Service() {
// this call to super is the one that times out
super(__getWsdlLocation(), MYSERVICE_QNAME);
}
I have tried the following but none of the solutions work.
Client Webservice in java - proxy authentication
Java Web Service client basic authentication
What can I do to call the web service from behind a proxy?
I was able to get this to work by adding the following code before the server instantiation:
System.setProperty("proxyHost", "myproxy.com");
System.setProperty("proxyPort", "8080");
Strangely this worked when I tested it by setting the VM options -DproxyHost and -DproxyPort so then searched for how to set it programmatically.
Related
I need to create a Java based XML web service client which is deployed in IBM WAS server which calls web service hosted by external system. Here 2 way ssl authentication mechanism should be there.
Configuration team has already set up the below things in quality environment of client and web service appservers:
At WAS server in which my web service client exists:
server certificate in the trustStore
client certificate is available in the keystore
At App server in which actual WebService exists:
server certificate in the keyStore
client certificate is available in the trust store
Coding:
we Auto generated classes using WSDL file provided by WS provider.
called the WS method normally like there is no 2 way ssl authentication mechanism in place.
problem: we are getting a connection exception when calling web service method from WS Client.Seems we have trouble with the 2 way ssl mechanism.
Full StackTrace Image as requested:
Assumptions:
we assumed that the entire handshake process of 2 way SSL process happens automatically when the web service call is done normally from the client.
Queries:
Is our assumption correct that entire handshake process happens
automatically here especially client sending its certificate ?
Do we need to specify at code level in java any details of path of
trust Store or KeyStore before calling the web service method to enable client to send its certificate ?
If Yes for Qn 2 do we need to set below properties in code as mentioned in some reference links
before calling WS method in client:
System.setProperty("javax.net.ssl.keyStore", "path/to/your/key");
System.setProperty("javax.net.ssl.keyStorePassword", "your-keystore- password");
System.setProperty("javax.net.ssl.trustStore","path/to/your/trust/keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "your-truststore-password");
Any suggestions/advice are highly welcome as we are stuck with this since few days.Its the first time we are working on web services which need 2 way SSL.
I have application that need to call Rest service, to do authentication process. The service and my application are in a same server. I used Spring RestTemplate to call it. When it tested in localhost, it works perfectly. But when I deploy it to the cloud server (in this case, Jelastic) I get this error:
I/O error on GET request for "[my_rest_service_address]":Connection refused; nested exception is java.net.ConnectException: Connection refused
All the code is follow this doc : http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html. Only the url that changed to my rest url.
Is it happened because jelastic server blocked outbound request? But, both the service and my application are in the same server, why it still blocked?
Please explain to me, what is the problem? Thanks
The http 401 code means that the user that made the request is not authenticated. It can be the user of your webapp or the user used for the rest call.
It can for example that different credentials are used in prod and test, different security schemes in each environment, etc.
I am working on a client which will request web service(hosted on internet) which requires NTLM authentication.
Also the host machine on which my client is installed is behind proxy, first the request should
authenticate proxy server and then request would go the web service and do NTLM authentication.
I am able to do NTLM authentication via the help on NTLM authentication
I have generated the stubs via wsimport by first saving wsdl file to local file because through URL I was not able to connect(because I dont know how to set proxy in command line call to wsimport).
I have not used any frameworks like axis2 or cxf. I am using Java 1.7
When I deploy the client on non-proxy machine(direct internet), then it works but not when behind proxy. Please help.
Following simple line of code to use System Proxy did the trick.
System.setProperty("java.net.useSystemProxies", "true");
I am connecting to a WCF web service with a Java client I am constructing. Someone else has already successfully built WCF clients to connect to this service. The WSDL available via HTTP provides Message Level Security. The WSDL available via HTTPS uses both TLS and Message Level Security. I understand that using TLS on top of Message Level Security is basically dual-encrypting, but that is a key requirement.
Since I can connect to the HTTP service correctly, I believe I have all the trust store and key store issues resolved.
I am connecting to the service using Metro 2.1.1. I have built the client in both Eclipse and Netbeans. I fetch the WSDL from the HTTP site, and using wsimport (with the -extensions flag) I build and execute the clients successfully.
When I fetch the WSDL using the HTTPS site I can again build both clients successfully. But when I execute them - I get the following error:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: An error occurred when verifying security for the message.
at com.sun.xml.ws.fault.SOAP12Fault.getProtocolException(SOAP12Fault.java:225)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:140)
at $Proxy43.request(Unknown Source)
The only difference between the two WSDLs (the one fetched via HTTP and the other via HTTPS) is the reference in the WSDL to HTTPS:// vs. HTTP://.
I do not have easy access to the WCF service logs - normally there is a 3-6 hour delay between when I request a set of logs and when I can view them.
My question is has anyone encountered a similar circumstance - and is there something I am blatantly missing here? Is there something in a NetMon or Wireshark trace I can look for to see that the issue is? I have been struggling with this for days - any help would be most appreciated.
If you have access to the service configuration try disabling security context on the endpoint you're using:
<message establishSecurityContext="False" clientCredentialType="UserName"/>
You can read more about security context token (SCT):
Security Context Token
Message security knobs
Java client for WCF service with wsHttpBinding over SSL
I have made a web service client importing a third party wsdl in eclipse.
But I got this exception:
javax.xml.ws.WebServiceException: Connection IO Exception. Check nested exception for details. (Unable to connect to 1X.XXX.X.XX:X0 - Connection timed out).
I hope this exception occurred for the proxy only.
There is a proxy server between me and that third party. I don't know how to do the proxy authentication and where in coding I need to this proxy authentication.
Is your end point on HTTPS? There different ways proxies support HTTPS - one ways is SSL bridging and the other is SSL Tunneling..
May be your client side libraries you used to connect may not support the one being used by the proxy...
You must explicitly set the proxy server in Java, the JRE does not retrieve it from the OS configuration. You can find the detailed explanation here. As per the link, a standard configuration may look like this:
System.setProperty("http.proxyHost", "myproxy.com");
System.setPropery("http.proxyPort", "8080");
Obviously, you can also define the system properties as VM arguments during startup.