问题:
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,而是在下边服务提供端里边我全出来红色的那段
消费端的接收借口:
1 package com.cxfc.service; 2 3 import java.util.List; 4 5 import javax.jws.WebService; 6 import javax.jws.soap.SOAPBinding; 7 import javax.jws.soap.SOAPBinding.Style; 8 9 import com.cxfc.entity.User; 10 11 @WebService(targetNamespace = "http://service.cxfs.com/", name = "ITest") 12 @SOAPBinding(style = Style.RPC) 13 public interface ITest { 14 15 public List<User> selectAllUser(); 16 17 public java.lang.String selectString(); 18 }
提供方服务端wsdl:
1 This XML file does not appear to have any style information associated with it. The document tree is shown below. 2 <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/"> 3 <wsdl:import location="http://192.168.3.53:8080/cxfservice/cxfservice/testServiceImpl?wsdl=ITest.wsdl" namespace="http://service.cxfs.com/"></wsdl:import> 4 <wsdl:binding name="TestImplServiceSoapBinding" type="ns1:ITest"> 5 <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 6 <wsdl:operation name="selectAllUser"> 7 <soap:operation soapAction="" style="rpc"/> 8 <wsdl:input name="selectAllUser"> 9 <soap:body namespace="http://service.cxfs.com/" use="literal"/> 10 </wsdl:input> 11 <wsdl:output name="selectAllUserResponse"> 12 <soap:body namespace="http://service.cxfs.com/" use="literal"/> 13 </wsdl:output> 14 </wsdl:operation> 15 <wsdl:operation name="selectString"> 16 <soap:operation soapAction="" style="rpc"/> 17 <wsdl:input name="selectString"> 18 <soap:body namespace="http://service.cxfs.com/" use="literal"/> 19 </wsdl:input> 20 <wsdl:output name="selectStringResponse"> 21 <soap:body namespace="http://service.cxfs.com/" use="literal"/> 22 </wsdl:output> 23 </wsdl:operation> 24 </wsdl:binding> 25 <wsdl:service name="TestImplService"> 26 <wsdl:port binding="tns:TestImplServiceSoapBinding" name="TestImplPort"> 27 <soap:address location="http://192.168.3.53:8080/cxfservice/cxfservice/testServiceImpl"/> 28 </wsdl:port> 29 </wsdl:service> 30 </wsdl:definitions>