如何发布自己的类型化WSDL?

时间:2015-05-27 04:40:15

标签: java web-services tomcat wsdl jax-ws

我正在构建一个Web服务并在Tomcat上部署它。我已经有了一个wsdl for it,我想发布它,我已经尝试使用WebServiceProvider注释的wsdlLocation属性进行指定,但Tomcat(?)只是生成它自己的。 编辑:不,它只是抛出异常,它正在生成自己的WSDL,因为我还没有重新启动Tomcat。

你应该知道的事情 -

  1. WSDL本身是有效的(格式化),我设法从它创建客户端存根。
  2. 我正在使用JAX-WS Provider接口,它只有一个方法-invoke。
  3. 但是我不希望CLIENT看到这个方法,而是让它看到,说另一个方法说GetFirstName采用sting而不是SOAPMessage.Later我可能想添加两个或三个方法,但是在服务器端处理XML级别。
  4. 提供者类 -

    package impl;
    
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.ws.ServiceMode;
    import javax.xml.ws.WebServiceProvider;
    import javax.xml.ws.BindingType;
    import javax.xml.ws.Provider;
    import javax.xml.ws.Service;
    
    @WebServiceProvider(portName="ClassRegisterBoyPort",wsdlLocation="/home/aneeshb/serverandclients/providerdeploy/ClassRegister/WebContent/WEB-INF/wsdl/stock.wsdl")
    @ServiceMode(value=Service.Mode.MESSAGE)
    @BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
    public class ClassRegisterBoyPort implements Provider<SOAPMessage>{
    
        @Override
        public SOAPMessage invoke(SOAPMessage msg) {
    
            try {
                OutputStream os = new FileOutputStream("testingboy.xml");
                msg.writeTo(os);
            } catch (SOAPException | IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
    
            return null;
        }
    
    }
    

    我正在尝试使用的WSDL -

    <?xml version='1.0' encoding='UTF-8'?>
    <wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://impl/"
        xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
        name="ClassRegisterService" targetNamespace="http://impl/">
        <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:tns="http://impl/" attributeFormDefault="unqualified"
                elementFormDefault="qualified" targetNamespace="http://impl/">
                <xsd:element name="GetFirstNameInput" nillable="true" />
                <xsd:complexType name="input">
                    <xsd:all>
                        <xsd:element name="firstName" type="xsd:string" />
                        <xsd:element name="lastName" type="xsd:string" />
                    </xsd:all>
                </xsd:complexType>
                <xsd:element name="GetFirstNameOutput" type="xsd:anyType" />
                <xsd:complexType  name="output">
                    <xsd:all>
                        <xsd:element name="firstName" type="xsd:string" />
                        <xsd:element name="lastName" type="xsd:string" />
                    </xsd:all>
                </xsd:complexType>
            </xsd:schema>
        </wsdl:types>
    
        <wsdl:message name="GetFirstNameInput">
            <wsdl:part element="tns:GetFirstNameInput" name="GetFirstNameInput">
            </wsdl:part>
        </wsdl:message>
        <wsdl:message name="GetFirstNameOutput">
            <wsdl:part element="tns:GetFirstNameOutput" name="GetFirstNameOutput">
            </wsdl:part>
        </wsdl:message>
    
        <wsdl:portType name="ClassRegisterBoyPortType">
            <wsdl:operation name="GetFirstName">
                <wsdl:input message="tns:GetFirstNameInput" name="GetFirstNameInput">
                </wsdl:input>
                <wsdl:output message="tns:GetFirstNameOutput" name="GetFirstNameOutput">
                </wsdl:output>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="ClassRegisterBoyBinding" type="tns:ClassRegisterBoyPortType">
            <soap12:binding style="document"
                transport="http://schemas.xmlsoap.org/soap/http" />
            <wsdl:operation name="GetFirstName">
                <soap12:operation soapAction="" style="document" />
                <wsdl:input name="GetFirstNameInput">
                    <soap12:body use="literal" />
                </wsdl:input>
                <wsdl:output name="GetFirstNameOutput">
                    <soap12:body use="literal" />
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="ClassRegisterService">
            <wsdl:port binding="tns:ClassRegisterBoyBinding" name="ClassRegisterBoyPort">
                <soap12:address
                    location="http://localhost:8180/ClassRegister/services/ClassRegister/boys" />
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    

    它生成的WSDL -

    <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://impl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="ClassRegisterBoyPortService" targetNamespace="http://impl/">
      <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://impl/" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://impl/">
      <xsd:element name="invoke" nillable="true" type="xsd:anyType"/>
      <xsd:element name="invokeResponse" nillable="true" type="xsd:anyType"/>
    </xsd:schema>
      </wsdl:types>
      <wsdl:message name="invoke">
        <wsdl:part element="tns:invoke" name="invoke">
        </wsdl:part>
      </wsdl:message>
      <wsdl:message name="invokeResponse">
        <wsdl:part element="tns:invokeResponse" name="invokeResponse">
        </wsdl:part>
      </wsdl:message>
      <wsdl:portType name="ClassRegisterBoyPort">
        <wsdl:operation name="invoke">
          <wsdl:input message="tns:invoke" name="invoke">
        </wsdl:input>
          <wsdl:output message="tns:invokeResponse" name="invokeResponse">
        </wsdl:output>
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="ClassRegisterBoyPortServiceSoapBinding" type="tns:ClassRegisterBoyPort">
        <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="invoke">
          <soap12:operation soapAction="" style="document"/>
          <wsdl:input name="invoke">
            <soap12:body use="literal"/>
          </wsdl:input>
          <wsdl:output name="invokeResponse">
            <soap12:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="ClassRegisterBoyPortService">
        <wsdl:port binding="tns:ClassRegisterBoyPortServiceSoapBinding" name="ClassRegisterBoyPort">
          <soap12:address location="http://localhost:8180/ClassRegister/services/ClassRegister/boys"/>
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    

    编辑:

    错误 -

    WARNING: Exception encountered during context initialization - cancelling refresh attempt
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxwsService': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://impl/}ClassRegisterBoyPortService.
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
        at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5231)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5518)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
    Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://impl/}ClassRegisterBoyPortService.
        at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:158)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:405)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261)
        at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
        at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
        at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
        at org.apache.cxf.jaxws.spring.NamespaceHandler$SpringServerFactoryBean.create(NamespaceHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1696)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1635)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
        ... 24 more
    
    May 27, 2015 4:41:42 PM org.apache.catalina.core.ApplicationContext log
    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jaxwsService': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://impl/}ClassRegisterBoyPortService.
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
        at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5231)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5518)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
    Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://impl/}ClassRegisterBoyPortService.
        at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:158)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:405)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261)
        at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
        at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
        at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
        at org.apache.cxf.jaxws.spring.NamespaceHandler$SpringServerFactoryBean.create(NamespaceHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1696)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1635)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
        ... 24 more
    
    May 27, 2015 4:41:42 PM org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /ClassRegister threw load() exception
    org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://impl/}ClassRegisterBoyPortService.
        at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:158)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:405)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:525)
        at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261)
        at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
        at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
        at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
        at org.apache.cxf.jaxws.spring.NamespaceHandler$SpringServerFactoryBean.create(NamespaceHandler.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1696)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1635)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
        at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5231)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5518)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
    

    提前致谢:P。

1 个答案:

答案 0 :(得分:0)

好吧,查看错误消息,我发现问题出在cxf-servlet.xml文件中。 最初是 -

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    <jaxws:server id="jaxwsService" serviceClass="impl.ClassRegisterBoyPort" address="/ClassRegister/boys">
        <jaxws:serviceBean>
            <bean class="impl.ClassRegisterBoyPort"/>
        </jaxws:serviceBean>
    </jaxws:server>
</beans>

由于错误表明它正在寻找我之前没有提到过的“ClassRegisterBoyPortService”,我认为CXFServlet配置为在指定的wsdl中查找其配置文件中指定的服务 - 因为我没有指定它只是将“服务”附加到实现者并寻找它。所以我在配置文件中指定了wsdlLocation,然后指定了serviceName,然后在找不到端口时指定了portName。瞧!它奏效了。

生成的cxf-servlet.xml是 -

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd" xmlns:tns="http://impl/">
    <jaxws:server id="jaxwsService" serviceClass="impl.ClassRegisterBoyPort" address="/ClassRegister/boys" wsdlLocation="serverandclients/providerdeploy/ClassRegister/WebContent/WEB-INF/wsdl/stock.wsdl" serviceName="tns:ClassRegisterService" endpointName="tns:ClassRegisterBoyPort">
        <jaxws:serviceBean>
            <bean class="impl.ClassRegisterBoyPort"/>
        </jaxws:serviceBean>
    </jaxws:server>
</beans>