简体   繁体   中英

Webservice client generation - stubs vs. Soap messages

I need help with choosing an approach and take certain actions based on that help or advise if I can get it.

I am given a URL to a wsdl If I generate stubs, I am using the functionality of that webservice I generate stubbs 3 different ways - (some redundant) - Eclipse - Ant commands (creates the same structure as with an eclipse) - using maven

<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>

maven creates a slightly different API, but - all workable.

Now, I am given a URL, that I am also generating an API, and able to make a call, however, get an error back - error is system specific. It means, I do have communication with the webservice functionality.

So, the owners of webservice send me the sample code - they are using SOAP Messages to talk to the webservice. And it works fine.

// Create SOAP Connection
            SOAPConnectionFactory soapConnectionFactory = null;
            SOAPConnection soapConnection = null;
            soapConnectionFactory = SOAPConnectionFactory.newInstance();
            soapConnection = soapConnectionFactory.createConnection();

            System.setProperty("https.protocols", 
             "TLSv1,TLSv1.1,TLSv1.2");
            System.setProperty("java.net.useSystemProxies", "true");

            String url = "https://someUrl?wsdl";
            SOAPMessage soapResponse = 
            soapConnection.call(createSOAPRequest(), url);

            // Process the SOAP Response
            try { 
                String op = printSOAPResponse(soapResponse);
                System.out.println("Res" +op);
            } catch (Exception e) {
                e.printStackTrace();
            }

I know that this is not very reliable and easy way of working with webservices. So, should I force, the webservice owners to do something, to fix the issue, or is there something I am not adding in my stubs, .. or whatever else can go wrong here ?

What is the general advise you could give ?

Thanks

Disclaimer: This is opinion based answer because of the nature of the question.

should I force, the webservice owners to do something, to fix the issue, or is there something I am not adding in my stubs, .. or whatever else can go wrong here

In SOAP, two parties are involved, the server and the client. And then between them there is contract called as WSDL . SO if they have provided you WSDL , you should be able to generated the specific SOAP message that server should be able to understand. Hence, you try solving the client side problem without forcing them. I'm less sure about your actual use case and SOAP services you are trying to consume, but usually service providers(ie SOAP Service) stick to protocols and then clients need to adjust in order to consume that specific service unless and otherwise you are too big of client to them and could force them to change their system that may be serving other customers(SOAP clients.). As an example, if you are using Azure or SAP SOAP service to use specific service, you are bound to make the messages that Azure or SAP could understand(though such big players provide their SDK to deal with such unnecessary headaches).

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