title: Call web service method from Java SE program
body: <p>How can I call a web service method from java desktop client. Basically my java program is running on a desktop which is internet enabled. My web service url is eg. <code>localhost:8090/Service.svc</code>, This web service is basically store data in database we just need to call a web service method and pass a xml string as parameter.</p>
  
  <h3>My sample code is look like:</h3>
  
  <pre><code>public static void main(String [] args)
      {
          String accessURL,method, parameters[];
          try {
  
              String xml = "&lt;DocumentElement&gt;"
                          + "&lt;Table1&gt;"
                          + "&lt;ConsumptionID&gt;0&lt;/ConsumptionID&gt;"
                          + "&lt;ConsumptionDate&gt;2012/01/01 00:00:00&lt;/ConsumptionDate&gt;"
                          + "&lt;MeterNumber&gt;99999901&lt;/MeterNumber&gt;"
                          + "&lt;Voltage&gt;200&lt;/Voltage&gt;"
                          + "&lt;Ampere&gt;50&lt;/Ampere&gt;"
                          + "&lt;PowerFactor&gt;0.91&lt;/PowerFactor&gt;"
                          + "&lt;KiloWatt&gt;8525&lt;/KiloWatt&gt;"
                          + "&lt;HourValue&gt;3&lt;/HourValue&gt;"
                          + "&lt;EndKiloWattHour&gt;5841&lt;/EndKiloWattHour&gt;"
                          + "&lt;KVA&gt;1000&lt;/KVA&gt;"
                          + "&lt;ClientID&gt;1011&lt;/ClientID&gt;"
                          + "&lt;CreatedBy&gt;1&lt;/CreatedBy&gt;"
                          + "&lt;/Table1&gt;"
                          + "&lt;/DocumentElement&gt;";
  
              accessURL = "http://localhost:8090/Service.svc";
              method = "Save_Consumption";
              parameters = new String[1];
  
              parameters[0] = xml;
              Service service = new Service();
              Call call = (Call)service.createCall();
              call.setTargetEndpointAddress(new java.net.URL(accessURL));
              call.setOperationName(method);
              Object[] params = new Object[parameters.length];
              params[0]=(Object)(parameters[0]);
              String retval = (String)call.invoke(params);
              System.out.println("Operation Result: " + retval);
          } catch(Exception e) {
              System.err.println(e.toString());
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <h3>But it shows exceptions, here is the stack trace.</h3>
  
  <pre><code>run:
  - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
  The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
  AxisFault
   faultCode: {http://schemas.microsoft.com/ws/2005/05/addressing/none}ActionNotSupported
   faultSubcode: 
   faultString: The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
   faultActor: 
   faultNode: 
   faultDetail: 
      {http://xml.apache.org/axis/}stackTrace:The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
      at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
      at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
      at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1741)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
      at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
      at org.apache.axis.client.Call.invoke(Call.java:2767)
      at org.apache.axis.client.Call.invoke(Call.java:2443)
      at org.apache.axis.client.Call.invoke(Call.java:2366)
      at org.apache.axis.client.Call.invoke(Call.java:1812)
      at com.lmeasure.utils.HelloClient.main(HelloClient.java:54)
  
      {http://xml.apache.org/axis/}hostname:eeipldt0132
  
  The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
      at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
      at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
      at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1741)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
      at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
      at org.apache.axis.client.Call.invoke(Call.java:2767)
      at org.apache.axis.client.Call.invoke(Call.java:2443)
      at org.apache.axis.client.Call.invoke(Call.java:2366)
      at org.apache.axis.client.Call.invoke(Call.java:1812)
      at com.lmeasure.utils.HelloClient.main(HelloClient.java:54)
  </code></pre>
  
  <p>Can anyone know whats wrong with that or provide me any good tutorial/working example to resolve my issue?</p>