简体   繁体   中英

Invoking SOAP methods JAX-WS

I have the following problem and would really appreciate any pointers:

I am trying to implement a SOAP service using a top-down approach - I have been given a WSDL file and am supposed to write a soap service that corresponds to it.

I generated the necessary files using wsgen - so far so good. I am now trying to do an initial test and prove that the service works, but have been unsuccessful. This is one of the methods that was generated, the echo method:

@WebMethod(operationName = "Echo", action = "http://tempuri.org/echo")
@RequestWrapper(localName = "Echo", targetNamespace = "http://tempuri.org/", className = "org.tempuri.Echo")
@ResponseWrapper(localName = "EchoResponse", targetNamespace = "http://tempuri.org/", className = "org.tempuri.EchoResponse")
public void echo(@WebParam(name = "DatumTimePost", targetNamespace = "http://tempuri.org/") String dateTimePost,
        @WebParam(name = "EchoResult", targetNamespace = "http://tempuri.org/", mode = WebParam.Mode.OUT) Holder<String> echoResult,
        @WebParam(name = "DateTimeExt", targetNamespace = "http://tempuri.org/", mode = WebParam.Mode.OUT) Holder<String> DateTimeExt);

The method is a part of a service named Service1Soap, which has the following annotations:

@WebService(name = "Service1Soap", targetNamespace = "http://tempuri.org/")
@XmlSeeAlso({
    ObjectFactory.class
})

I exposed the service using an Endpoint:

Endpoint.publish("http://localhost:8080/ws/hello", new Service1SoapImpl());

However, when I try to invoke the Echo method using SoapUI, here is what I get as a response:

<faultstring>Cannot find dispatch method for {http://tempuri.org/echo}Echo</faultstring>

I try to invoke the method by putting http://localhost:8080/ws/hello in the request uri field in SoapUI, while the request itself has been generated by SOAPUI itself after importing the wsdl.

I have pretty much run out of ideas regarding what I am doing wrong so any sort of hope would be greatly appreciated.

For what you've posted, this is the only difference I can find:

Endpoint.publish("http://localhost:8080/ws/hello", new Service1Soap()
{

    @Override
    public String uparivanje(String datum, String spisakTransakcija)
    {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void storno(String idTransakcijaStornoPosta, String idTransakcijaPosta, String posta, String idRadnik, String datumVreme, Holder<String> stornoResult, Holder<String> idTransakcijaStornoExt, Holder<String> brojTelefona, Holder<String> username)
    {
        // TODO Auto-generated method stub

    }

    @Override
    public void echo(String datumVremePosta, Holder<String> echoResult, Holder<String> datumVremeExt)
    {
        // TODO Auto-generated method stub
    }

    @Override
    public void dopuna(String idTransakcijaPosta, String idKorisnik, String iznos, String posta, String idRadnik, String datumVreme, Holder<String> dopunaResult, Holder<String> idTransakcijaExt, Holder<String> brojTelefona, Holder<String> username)
    {
        // TODO Auto-generated method stub

    }
});
Since I cannot post the wsdl as an answer to the comment above, I am pasting it here.
   <?xml version="1.0" encoding="utf-8"?>
    <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
          <s:element name="Dopuna">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="IdTransakcijaPosta" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdKorisnik" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="Iznos" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="Posta" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdRadnik" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="DatumVreme" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="DopunaResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="DopunaResult" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdTransakcijaExt" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="BrojTelefona" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="Storno">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="IdTransakcijaStornoPosta" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdTransakcijaPosta" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="Posta" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdRadnik" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="DatumVreme" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="StornoResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="StornoResult" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="IdTransakcijaStornoExt" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="BrojTelefona" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="Echo">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="DatumVremePosta" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="EchoResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="EchoResult" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="DatumVremeExt" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="Uparivanje">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="Datum" type="s:string" />
                <s:element minOccurs="0" maxOccurs="1" name="SpisakTransakcija" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="UparivanjeResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="UparivanjeResult" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
        </s:schema>
      </wsdl:types>
      <wsdl:message name="DopunaSoapIn">
        <wsdl:part name="parameters" element="tns:Dopuna" />
      </wsdl:message>
      <wsdl:message name="DopunaSoapOut">
        <wsdl:part name="parameters" element="tns:DopunaResponse" />
      </wsdl:message>
      <wsdl:message name="StornoSoapIn">
        <wsdl:part name="parameters" element="tns:Storno" />
      </wsdl:message>
      <wsdl:message name="StornoSoapOut">
        <wsdl:part name="parameters" element="tns:StornoResponse" />
      </wsdl:message>
      <wsdl:message name="EchoSoapIn">
        <wsdl:part name="parameters" element="tns:Echo" />
      </wsdl:message>
      <wsdl:message name="EchoSoapOut">
        <wsdl:part name="parameters" element="tns:EchoResponse" />
      </wsdl:message>
      <wsdl:message name="UparivanjeSoapIn">
        <wsdl:part name="parameters" element="tns:Uparivanje" />
      </wsdl:message>
      <wsdl:message name="UparivanjeSoapOut">
        <wsdl:part name="parameters" element="tns:UparivanjeResponse" />
      </wsdl:message>
      <wsdl:portType name="Service1Soap">
        <wsdl:operation name="Dopuna">
          <wsdl:input message="tns:DopunaSoapIn" />
          <wsdl:output message="tns:DopunaSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="Storno">
          <wsdl:input message="tns:StornoSoapIn" />
          <wsdl:output message="tns:StornoSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="Echo">
          <wsdl:input message="tns:EchoSoapIn" />
          <wsdl:output message="tns:EchoSoapOut" />
        </wsdl:operation>
        <wsdl:operation name="Uparivanje">
          <wsdl:input message="tns:UparivanjeSoapIn" />
          <wsdl:output message="tns:UparivanjeSoapOut" />
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="Dopuna">
          <soap:operation soapAction="http://tempuri.org/Dopuna" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Storno">
          <soap:operation soapAction="http://tempuri.org/Storno" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Echo">
          <soap:operation soapAction="http://tempuri.org/Echo" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Uparivanje">
          <soap:operation soapAction="http://tempuri.org/Uparivanje" style="document" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="Dopuna">
          <soap12:operation soapAction="http://tempuri.org/Dopuna" style="document" />
          <wsdl:input>
            <soap12:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap12:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Storno">
          <soap12:operation soapAction="http://tempuri.org/Storno" style="document" />
          <wsdl:input>
            <soap12:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap12:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Echo">
          <soap12:operation soapAction="http://localhost:8080/ws/hello" style="document" />
          <wsdl:input>
            <soap12:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap12:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="Uparivanje">
          <soap12:operation soapAction="http://tempuri.org/Uparivanje" style="document" />
          <wsdl:input>
            <soap12:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap12:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="Service1">
        <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
          <soap:address location="http://localhost:32663/Service1.asmx" />
        </wsdl:port>
        <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
          <soap12:address location="http://localhost:32663/Service1.asmx" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM