简体   繁体   中英

“javax.xml.ws.WebServiceException: is not a valid service.” proxy issue?

As a premise, I am not very experienced yet, but I have tried to read and search everything I possibly could, related to this topic, and still no luck.

I was given a simple client to call a webservice but once it was fully setup (which included the use of a certificate and a couple more properties to set) I got the error mentioned in the title:

javax.xml.ws.WebServiceException: {http://http://cert.controller.portaapplicativa.ictechnology.it//}MyService is not a valid service. Valid services are: 
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:187)
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:159)
    at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
    at javax.xml.ws.Service.<init>(Service.java:56)
    at package.client.wsimport.MyService..<init>(MyService.java:46)
    at package.client.Client.doRicercaDEN(Client.java:55)
    at package.client.Client.main(Client.java:36)

I tried generating the client again with JAX-WS:

java -classpath C:\Programmi\Java\jdk1.6.0_38\lib\tools.jar com.sun.tools.internal.ws.WsImport -verbose C:\WsdlFile.wsdl -p package.client.wsimport -s C:\tmp\ws\

And I get the same issue. I am using a local copy of the wsdl because wsimport doesn't seem to like the certificate I'm trying to set in the properties (I'm most likely doing something wrong, but I opted for the simple workaround, given I have more pressing issues).

Trying to use SoapUI to test the service, everything works fine, though I need to set the preferences for the proxy to "None".

So I tried to make sure the connection doesn't use any proxy in my client as well:

(...)
systemSettings.remove("http.proxyHost");
systemSettings.remove("http.proxyPort");
systemSettings.remove("https.proxyHost");
systemSettings.remove("https.proxyPort");
System.setProperty("http.nonProxyHosts","*");
System.setProperty("https.nonProxyHosts","*");

(BTW, before "*", which as I understand it should work as a wildcard for "every domain", I have tried specifying the specific domains as well) Anyway, the result is always the same.

Is there something I am doing wrong, something left to try?

I doubt this is a proxy issue. If you can share the code you are using to create the Service object it might help.
As a kick start try reading the below thread
Is not a valid service exception in JAX-WS
What I think is that the QName you have provided when creating the Service is not proper. To get the correct QName you might try to open the generated stub.

As it turns out, what I was missing was importing the certificate in my local truststore (or better, when I first tried doing so, I thought I was using the correct truststore, but I wasn't).

For anyone who may need it, here is an explanation of how to do that using keytool: http://javarevisited.blogspot.it/2012/03/add-list-certficates-java-keystore.html

Another option is to use specific GUI like Portecle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM