调用 SOAP 方法 JAX-WS

Invoking SOAP methods JAX-WS

我遇到以下问题,非常感谢任何指点:

我正在尝试使用自上而下的方法实现 SOAP 服务 - 我已经获得了一个 WSDL 文件,我应该编写一个与之对应的 soap 服务。

我使用 wsgen 生成了必要的文件 - 到目前为止一切顺利。我现在正在尝试进行初步测试并证明该服务有效,但没有成功。这是生成的方法之一,echo方法:

@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);

该方法是名为 Service1Soap 的服务的一部分,该服务具有以下注释:

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

我使用端点公开了服务:

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

但是,当我尝试使用 SoapUI 调用 Echo 方法时,得到的响应如下:

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

我尝试通过在 SoapUI 的请求 uri 字段中放置 http://localhost:8080/ws/hello 来调用该方法,而请求本身是在导入 wsdl 后由 SOAPUI 本身生成的。

对于我做错了什么,我几乎 运行 没有任何想法,所以任何形式的希望都将不胜感激。

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>

对于您发布的内容,这是我能找到的唯一区别:

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

    }
});