0

我是 Web 服务的新手,我买了一本书并开始从中学习,WSDL 是:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ttdev.com/ss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SimpleService" targetNamespace="http://ttdev.com/ss">
  <wsdl:types>
    <xsd:schema targetNamespace="http://ttdev.com/ss">
      <xsd:element name="concatRequest">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="s1" type="xsd:string" />
            <xsd:element name="s2" type="xsd:string"></xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="concatResponse" type="xsd:string">

      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="concatRequest">
    <wsdl:part element="tns:concatRequest" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="concatResponse">
    <wsdl:part element="tns:concatResponse" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="SimpleService">
    <wsdl:operation name="concat">
      <wsdl:input message="tns:concatRequest"/>
      <wsdl:output message="tns:concatResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="SimpleServiceSOAP" type="tns:SimpleService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="concat">
      <soap:operation soapAction="http://ttdev.com/ss/NewOperation"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="SimpleService">
    <wsdl:port binding="tns:SimpleServiceSOAP" name="p1">
      <soap:address location="http://localhost:8080/ss/p1"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

我运行 SimpleService_P1_Server,它正在工作,但是当我运行客户端时: SimpleService_P1_Client 我得到了这个异常:

Apr 8, 2012 9:51:47 AM com.ttdev.ss.SimpleService_Service <clinit>
INFO: Can not initialize the default wsdl from src/main/resources/SimpleService.wsdl
Exception in thread "main" javax.xml.ws.WebServiceException: Port {http://ttdev.com/ss}p1 not found.
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:328)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
    at javax.xml.ws.Service.getPort(Unknown Source)
    at com.ttdev.ss.SimpleService_Service.getP1(SimpleService_Service.java:56)
    at com.ttdev.ss.SimpleService_P1_Client.main(SimpleService_P1_Client.java:49)

谢谢,感谢您的帮助。

4

1 回答 1

0

前段时间我也遇到过类似的问题。您可能希望在“src/main/resources”之前使用前缀“file:”。这是结果代码:

WSDLToJava.main(new String[] { "-client", "-d", "src/main/java",
            "file:src/main/resources/SimpleService.wsdl" });
于 2012-12-30T05:01:34.447 回答