Reputation: 5167
As I said in headline I am trying to hookup JAVA application to remote web service. I am pretty new to JAVA and Web Services. I am using Eclipse IDE.
First thing I've done was to run wsimport in command window. Provided WSDL url, but got error: FAILED, Could not find WSDL. I checked multiple times to make sure that url is correct.
To go around, I saved WSDL locally and thean wsimport didn't have any issues. Moved all generated code to my project and everything seems fine.
Here is my test code
// HAVE TO USE PROXY
final String authUser = "xxxxxx";
final String authPassword = "xxxxxx";
String proxyServer = "proxy1.xxxxx.com";
String proxyPort = "99999";
System.setProperty("http.proxyHost", proxyServer);
System.setProperty("http.proxyPort", proxyPort);
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
Authenticator.setDefault(
new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(authUser, authPassword.toCharArray());
}
}
);
WebServiceXX client = new WebServiceXX();
WebServiceXXSoap port = client.getPort(WebServiceXXSoap.class);
BindingProvider bp = (BindingProvider)port;
Map<String, Object> req_ctx = bp.getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://domain.com/WebService/WebServiceXX.asmx");
req_ctx.put(BindingProvider.USERNAME_PROPERTY, "user");
req_ctx.put(BindingProvider.PASSWORD_PROPERTY, "password");
//HERE, TRYING TO CALL SERVICE. GETTING TIMEOUT ERROR IN 2nd LINE
WebServiceXXSoap service = client.getWebServiceXXSoap();
OperationStatusCodesResp StatusCodes = service.GetOperationStatusCodes();
In short, I had to use Proxy server. I tested that part and it seems that is fine. Since I used local WSDL, I assume that I have to manually set ENDPOINT URL, and since authentication is required, I had to set username and password as you can see it in the code.
The error I am getting is Time Out Error. I am thinking that maybe I didn't set this ENDPOINT properly and that request cannot be made since there is no proper web service url provided.
I tried to edit wsdlLocation in one of the generated java files, to replace local path with real WSDL url, but I am getting error that WSDL can't be found. JAX-WS simply either hate this WSDL or something else is problem. As a note, I didn't have any issues utilizing this service in .NET (C#) application (Web service itself is done in .NET, WSE 2.0)
Any ideas?
Thanks
Upvotes: 0
Views: 3738
Reputation: 42060
You can try change the wsdlLocation
of @WebServiceClient
annotation and the variable baseUrl
to.
https://domain.com/WebService/WebServiceXX.asmx?WSDL
For authentication (basic), you can find a good guide in HTTP basic authentication with JAX-WS (Client).
You can try Storing the WSDL Locally in your project. For generate the client you can put the WSDL file in a folder, then navigate to the folder using the terminal o symbol system, set the PATH
for point the bin
folder of JDK, and use wsimport
with the local wsdl file.
See an example in Consuming a Web Service with Java 6 and JAX-WS - Wiki - Confluence.
Then you can use the way in the Specifying the Endpoint Address and HTTP Basic Authorization section.
Upvotes: 1