Java – jax-ws and saaj style, which one is used

What is the difference, philosophical or otherwise, between using the service and dispatch class and the soapconnection class to call java code?

For example, something like this:

SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = scf.createConnection();
SOAPMessage reply = soapConnection.call(soapMessage,url);

About along these lines?

svc = Service.create(url,serviceName);
Dispatch<SOAPMessage> dispatch = svc.createDispatch(portName,SOAPMessage.class,service.Mode.MESSAGE);
SOAPMessage reply = (SOAPMessage)dispatch.invoke(soapMessage);

What is the difference between these and why choose one method?

Solution

The following line is taken from the Java SOA Cookbook – O'Reilly

"Soap connection allows you to send SOAP messages to a URL at the end of the resource. This is convenient in any case, but if the service does not have a WSDL, it is necessary to have a defined WSDL. This is because calling service.create needs to pass the location of the WSDL. You may rarely have a WSDL service without soap, but it does happen, and you will be ready

To create a connection to a web service that does not expose WSDL, you can use the soapconnection class to communicate directly with remote resources Then, you will create a URL object resource (servlet) representing the remote that you want to call Passing the soap request message and endpoint, you want to call the calling method on the connection object and wait for it to return a soap response

• passed to connection The endpoint URL of the call method can be a string or a Java net. URL“.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>