问题:
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Could not find portType named {http://service.cxfc.com/}ITest
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:345)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:338)
at javax.xml.ws.Service.getPort(Service.java:188)
at com.cxfc.controller.MyTest.main(MyTest.java:23)
解决方法:
将消费端的接收接口@WebService改成@WebService(targetNamespace = "http://service.cxfs.com/", name = "ITest"),targetNamespace对应的就是出错显示上面蓝色的那段,不过这个targetNamespace并不对应服务提供端的targetNamespace,而是在下边服务提供端里边我全出来红色的那段
消费端的接收借口:
package com.cxfc.service; import java.util.List; import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style; import com.cxfc.entity.User; @WebService(targetNamespace = "http://service.cxfs.com/", name = "ITest")
@SOAPBinding(style = Style.RPC)
public interface ITest { public List<User> selectAllUser(); public java.lang.String selectString();
}
提供方服务端wsdl:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://impl.service.cxfs.com/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http"
xmlns:ns1="http://service.cxfs.com/" name="TestImplService" targetNamespace="http://impl.service.cxfs.com/">
<wsdl:import location="http://192.168.3.53:8080/cxfservice/cxfservice/testServiceImpl?wsdl=ITest.wsdl" namespace="http://service.cxfs.com/"></wsdl:import>
<wsdl:binding name="TestImplServiceSoapBinding" type="ns1:ITest">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="selectAllUser">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input name="selectAllUser">
<soap:body namespace="http://service.cxfs.com/" use="literal"/>
</wsdl:input>
<wsdl:output name="selectAllUserResponse">
<soap:body namespace="http://service.cxfs.com/" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="selectString">
<soap:operation soapAction="" style="rpc"/>
<wsdl:input name="selectString">
<soap:body namespace="http://service.cxfs.com/" use="literal"/>
</wsdl:input>
<wsdl:output name="selectStringResponse">
<soap:body namespace="http://service.cxfs.com/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestImplService">
<wsdl:port binding="tns:TestImplServiceSoapBinding" name="TestImplPort">
<soap:address location="http://192.168.3.53:8080/cxfservice/cxfservice/testServiceImpl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>