reficio / soap-ws

Java library, based on Spring-WS, that enables handling SOAP on a purely XML level
297 stars 145 forks source link

HTTPS Endpoints #34

Open anavarrd opened 9 years ago

anavarrd commented 9 years ago

Hello,

I am using your jar to create dinamic ws client in java. You have done a good job with this .jar All was going good until I have to connect with https endpoint.

This is my example code:


String wsdl="https://des-gesat.redsara.es/ws/catalog/services/call/carpetaciudadana?wsdl"; String bindingName = "WS_Services_CarpetaciudadanaBinding"; String operationName = "consultaExpedientes"; String endpointUrl="https://des-gesat.redsara.es/ws/catalog/services/call/carpetaciudadana"; String request="... my request ....</soapenv:Envelope>"; int timeout=1000; // WSDL final Wsdl wsdl = Wsdl.parse(wsdl);

// CLIENT final SoapBuilder soapBuilder = wsdl.binding().localPart(bindingName).find();
final SoapOperation operation = soapBuilder.operation().name(operationName).find(); final Builder builder = SoapClient.builder(); builder.connectTimeoutInMillis(timeout); URI endpointURI = new URI(endpointUrl); builder.endpointUri(endpointURI); final SoapClient client = builder.build(); // RESPONSE final String response = client.post(operation.getSoapAction(), request);


In this case, at line final SoapClient client = builder.build() throws this exception: java.lang.IllegalArgumentException: Port is invalid: -1

If I use the following endpoint url it works but the server dont listen prorperly to the url. endpointUrl="https://des-gesat.redsara.es:443/ws/catalog/services/call/carpetaciudadana";

How can I use https endpoint without including the port in the url?

Thank you so much. Im looking forward your answer.

cfalzone commented 8 years ago

Ever figure this out? I am having the same issue. Full stack trace:

2015-07-14 13:18:02,502 ERROR com.aquent.osgi.AquentActivator - Exception testing web service client
java.lang.IllegalArgumentException: Port is invalid
    at org.apache.http.util.Args.check(Args.java:36)
    at org.apache.http.conn.scheme.Scheme.<init>(Scheme.java:91)
    at org.reficio.ws.client.core.SoapClient.registerTlsScheme(SoapClient.java:249)
    at org.reficio.ws.client.core.SoapClient.configureTls(SoapClient.java:237)
    at org.reficio.ws.client.core.SoapClient.initialize(SoapClient.java:192)
    at org.reficio.ws.client.core.SoapClient.access$900(SoapClient.java:72)
    at org.reficio.ws.client.core.SoapClient$Builder.initializeClient(SoapClient.java:407)
    at org.reficio.ws.client.core.SoapClient$Builder.build(SoapClient.java:385)
    at com.aquent.osgi.AquentActivator.start(AquentActivator.java:75)
    at com.dotcms.repackage.org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
    at com.dotcms.repackage.org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
    at com.dotcms.repackage.org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:458)
    at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)
bashoogzaad commented 8 years ago

Same issue here! Would be great if somebody could post a workaround or fix...

bashoogzaad commented 8 years ago

UPDATE: When I add a port to the URI passed in the builder, I get the following exception:

Uncaught exception from servlet
org.reficio.ws.client.TransmissionException: HTTP response=[Internal Server Error] code=[500]
    at org.reficio.ws.client.core.SoapClient.executePost(SoapClient.java:171)
    at org.reficio.ws.client.core.SoapClient.transmit(SoapClient.java:161)
    at org.reficio.ws.client.core.SoapClient.post(SoapClient.java:116)
    at org.kiba.api.cif.GetBarcode.performGet(GetBarcode.java:87)
    at org.kiba.api.support.APIPage.doGet(APIPage.java:74)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)

Can you check if this is also the case in your situation? Then I can determine if it is the server's fault.

cfalzone commented 8 years ago

Well, for me, the fix was just to add port 443 to the url, though I know in some, or maybe most, cases that won't work as in the OP's and your cases. I think a workaround, if you wanted to internalize the code until a fix is made is to hardcode the port here:

https://github.com/reficio/soap-ws/blob/93e5a7956ed68b6125ab756e9c6cddea266a9dc6/soap-client/src/main/java/org/reficio/ws/client/core/SoapClient.java#L236

and/or here

https://github.com/reficio/soap-ws/blob/93e5a7956ed68b6125ab756e9c6cddea266a9dc6/soap-client/src/main/java/org/reficio/ws/client/core/SoapClient.java#L240

What happens is the port ends up being null in those cases.

Or perhaps a check here if port is null than set port to 443 or something?

https://github.com/reficio/soap-ws/blob/93e5a7956ed68b6125ab756e9c6cddea266a9dc6/soap-client/src/main/java/org/reficio/ws/client/core/SoapClient.java#L249

bashoogzaad commented 8 years ago

I just set the URI port like it is done here: http://stackoverflow.com/questions/6490014/modifying-the-port-of-a-uri . So it should find 443 and I think it does. So hardcoding is not the solution here. Could it be that the SOAP Server doesn't allow connections on this port (which would be very weird)?