title: How to make a SOAP call in Java
body: <p>This seems like it should be simple, but maybe I'm missing something. I just want to make a SOAP call in Java, preferrably using only built-in APIs. I'm a little overwhelmed looking at <a href="http://java.sun.com/javase/6/docs/api/javax/xml/soap/package-summary.html" rel="nofollow noreferrer">javax.xml.soap</a> package in the Java documentation.  I have tried searching Google, but it seems like all the results are from 2000-2002, and they are all talking about libraries that can be used for SOAP calls (before SOAP libraries were built in, I guess).</p>
  
  <p>I don't need to handle the SOAP request; only make one. <a href="http://oreilly.com/catalog/javaxml2/chapter/ch12.html" rel="nofollow noreferrer">This site</a> has an example that is pretty simple, but it doesn't use the built-in Java SOAP libraries.  How would I do basically the same thing using core Java?</p>
  
  <pre><code>// Create the parameters
  Vector params = new Vector(  );
  params.addElement(
      new Parameter("flightNumber", Integer.class, flightNumber, null));
  params.addElement(
      new Parameter("numSeats", Integer.class, 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
  </code></pre>