title: Creating a web service client from WSDL in java
body: <p>I have been searching for days on this, and finally figured I'd ask.  I'm new to java in general, and newer to web service functionality, so I'm struggling quite a bit.  I'm surprised I haven't found a step by step guide on this in all of the examples I've found on the net, but I'm sure there is something somewhere.  All I need to do is import a WSDL document into Java (done), and be able to invoke the web service from my class, send it a string, and have it return a response.  When I first import the WSDL into the project, there are several errors that exist.  The main one seems to be that it requires an interface named similar to the proxy class that was generated.  So I've done that, but other errors are in there as well.  Is it normal that you have to create code within the generated classes and do your own thing in there, or should the WSDL be more formatted and precise so that it's just plug and play?  I thought from a project I did years ago, that it was pretty much plug and play and you could just do import it and do String response = myService.call(String myString); and have it return a response just by referencing the classes generated by the WSDL.  Does anyone have any ideas where a beginner could learn how to invoke a web service based on a WSDL file?  I mean from square one, like what you need to import, where you need to get the .jar file references from (if needed), etc.  Just for reference, I am including the WSDL below.  Thanks for any insight!</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://listeners.webtools.integrator.myserver.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://listeners.webtools.integrator.myserver.com"&gt;
  &lt;wsdl:documentation&gt;MYListener&lt;/wsdl:documentation&gt;
  &lt;wsdl:types&gt;
    &lt;xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://listeners.webtools.integrator.myserver.com"&gt;
      &lt;xs:element name="processMessage"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:sequence&gt;
            &lt;xs:element minOccurs="0" name="inputMessage" nillable="true" type="xs:string"/&gt;
          &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
                          &lt;xs:element minOccurs="0" name="return"
                           nillable="true" type="xs:string"/&gt;
                  &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
      &lt;/xs:schema&gt;
  &lt;/wsdl:types&gt;
  
  &lt;wsdl:message name="processMessageRequest"&gt;
      &lt;wsdl:part name="parameters" element="ns:processMessage"/&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:message name="processMessageResponse"&gt;
      &lt;wsdl:part name="parameters" element="ns:processMessageResponse"/&gt;
  &lt;/wsdl:message&gt;
  &lt;wsdl:portType name="MYListenerPortType"&gt;
      &lt;wsdl:operation name="processMessage"&gt;
          &lt;wsdl:input message="ns:processMessageRequest" 
           wsaw:Action="urn:processMessage"/&gt;
          &lt;wsdl:output message="ns:processMessageResponse" 
           wsaw:Action="urn:processMessageResponse"/&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:portType&gt;
  &lt;wsdl:binding name="MYListenerSoap11Binding" 
   type="ns:MYListenerPortType"&gt;
      &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" 
       style="document"/&gt;
      &lt;wsdl:operation name="processMessage"&gt;
          &lt;soap:operation soapAction="urn:processMessage" 
           style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:binding name="MYListenerSoap12Binding" 
   type="ns:MYListenerPortType"&gt;
      &lt;soap12:binding transport="http://schemas.xmlsoap.org/soap/http" 
       style="document"/&gt;
      &lt;wsdl:operation name="processMessage"&gt;
          &lt;soap12:operation soapAction="urn:processMessage" 
           style="document"/&gt;
          &lt;wsdl:input&gt;
              &lt;soap12:body use="literal"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;soap12:body use="literal"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  
  &lt;wsdl:binding name="MYListenerHttpBinding" type="ns:MYListenerPortType"&gt;
      &lt;http:binding verb="POST"/&gt;
      &lt;wsdl:operation name="processMessage"&gt;
          &lt;http:operation location="processMessage"/&gt;
          &lt;wsdl:input&gt;
              &lt;mime:content type="application/xml" part="parameters"/&gt;
          &lt;/wsdl:input&gt;
          &lt;wsdl:output&gt;
              &lt;mime:content type="application/xml" part="parameters"/&gt;
          &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
  &lt;/wsdl:binding&gt;
  &lt;wsdl:service name="MYListener"&gt;
      &lt;wsdl:port name="MYListenerHttpSoap11Endpoint" 
       binding="ns:MYListenerSoap11Binding"&gt;
          &lt;soap:address location="http://10.221.55.206:20043/axis2/services/MYListener.MYListenerHttpSoap11Endpoint/"/&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="MYListenerHttpSoap12Endpoint" binding="ns:MYListenerSoap12Binding"&gt;
          &lt;soap12:address location="http://10.221.55.206:20043/axis2/services/MYListener.MYListenerHttpSoap12Endpoint/"/&gt;
      &lt;/wsdl:port&gt;
      &lt;wsdl:port name="MYListenerHttpEndpoint" binding="ns:MYListenerHttpBinding"&gt;
          &lt;http:address location="http://10.221.55.206:20043/axis2/services/MYListener.MYListenerHttpEndpoint/"/&gt;
      &lt;/wsdl:port&gt;
  &lt;/wsdl:service&gt;
  </code></pre>
  
  <p></p>