无法在javaee中使用webservice

时间:2017-05-30 17:56:59

标签: java web-services soap wildfly

我创建了webservice,如下所示:

@WebService
public class DefaultHolidayCalculatorWS {

@Inject
private HolidayCalculator holidayCalculator;

public Long getDaysTillHoliday() {
    return holidayCalculator.getDaysToHoliday();
}}

我把它作为对野蝇的战争。服务已成功创建。然后我创建了我的第二个应用程序(也是.war),其中包含:

@WebService
public interface HolidayCalculatorWS {
    Long getDaysTillHoliday();
}

和servlet:

@WebServlet("/soaptest")
public class SOAPTest extends HttpServlet {

@WebServiceRef(wsdlLocation = "http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS?wsdl" )
private HolidayCalculatorWS holidayCalculatorWS;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println(holidayCalculatorWS.getDaysTillHoliday());
}

}

在同一个wildfly服务器上将其部署为单独的.war。当我调用http get .../soaptest时,我收到了错误消息:'

  

引起:javax.xml.ws.WebServiceException:找不到服务   在wsdl中命名为null   http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS?wsdl     在   org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:173)     在org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)     在org.apache.cxf.jaxws.ServiceImpl。(ServiceImpl.java:129)at at   org.jboss.wsf.stack.cxf.client.ProviderImpl $ JBossWSServiceImpl。(ProviderImpl.java:572)     在   org.jboss.wsf.stack.cxf.client.ProviderImpl.createServiceDelegate(ProviderImpl.java:290)     在javax.xml.ws.Service。(Service.java:63)at   javax.xml.ws.Service.create(Service.java:710)at   org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceObjectFactoryJAXWS.instantiateService(CXFServiceObjectFactoryJAXWS.java:256)     在   org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceObjectFactoryJAXWS.getObjectInstance(CXFServiceObjectFactoryJAXWS.java:86)     ......还有68个

这个问题的原因是什么?

编辑:

WSDL:

<?xml version="1.0"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ws.app/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="DefaultHolidayCalculatorWSService" targetNamespace="http://ws.app/">
<wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.app/" elementFormDefault="unqualified" targetNamespace="http://ws.app/" version="1.0">
    <xs:element name="getDaysTillHoliday" type="tns:getDaysTillHoliday"/>
    <xs:element name="getDaysTillHolidayResponse" type="tns:getDaysTillHolidayResponse"/>
    <xs:complexType name="getDaysTillHoliday">
        <xs:sequence/>
    </xs:complexType>
    <xs:complexType name="getDaysTillHolidayResponse">
        <xs:sequence>
            <xs:element minOccurs="0" name="daysTillHoliday" type="xs:long"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getDaysTillHolidayResponse">
    <wsdl:part element="tns:getDaysTillHolidayResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getDaysTillHoliday">
    <wsdl:part element="tns:getDaysTillHoliday" name="parameters"/>
</wsdl:message>
<wsdl:portType name="HolidayCalculatorWS">
    <wsdl:operation name="getDaysTillHoliday">
        <wsdl:input message="tns:getDaysTillHoliday" name="getDaysTillHoliday"/>
        <wsdl:output message="tns:getDaysTillHolidayResponse" name="getDaysTillHolidayResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DefaultHolidayCalculatorWSServiceSoapBinding" type="tns:HolidayCalculatorWS">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getDaysTillHoliday">
        <soap:operation soapAction="" style="document"/>
        <wsdl:input name="getDaysTillHoliday">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="getDaysTillHolidayResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="DefaultHolidayCalculatorWSService">
    <wsdl:port binding="tns:DefaultHolidayCalculatorWSServiceSoapBinding" name="DefaultHolidayCalculatorWSPort">
        <soap:address location="http://localhost:8082/HolidayCalcWS/DefaultHolidayCalculatorWS"/>
    </wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 个答案:

没有答案
相关问题