How to make soap calls in Java

It should seem simple, but maybe I missed something I just want to make soap calls in Java, and it's best to use only the built-in API I saw javax in the Java documentation xml. Soap package, a little overwhelmed I have tried to search Google, but it seems that all the results are from 2000 to 2002. They are talking about libraries that can be used for soap calls (before I build soap libraries)

I don't need to process soap requests; Just make one This site has a very simple example, but it does not use the built-in Java soap library Using core Java, how can I do basically the same thing?

// Create the parameters
Vector params = new Vector(  );
params.addElement(
    new Parameter("flightNumber",Integer.class,flightNumber,null));
params.addElement(
    new Parameter("numSeats",numSeats,null));
params.addElement(
    new Parameter("creditCardType",String.class,creditCardType,null));
params.addElement(
    new Parameter("creditCardNumber",Long.class,creditCardNum,null));

// Create the Call object
Call call = new Call(  );
call.setTargetObjectURI("urn:xmltoday-airline-tickets");
call.setMethodName("buyTickets");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
call.setParams(params);

// Invoke
Response res = call.invoke(new URL("http://rpc.middleearth.com"),"");

// Deal with the response

Solution

Soap changed a lot in its early days You can do what you describe, but it's not common

It is now more common to use the wsdl2java tool to generate the client API from the WSDL description of the service This will give you a nice, clean API to call

Apache CXF is a place for such things

One condition is RPC / encoding If you are dealing with old services, it may be RPC / coding. In this case, the best choice is Apache axis 1 x. Everything else has escaped from RPC / encoded

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
分享
二维码
< <上一篇
下一篇>>