CXF:没有找到 WSDL 操作的方法

CXF : No method was found for the WSDL operation

我已经为此苦苦挣扎了 2 天,所以我必须寻求帮助。

我有一个使用 Spring 的多面 Maven 项目。

GesAction
-ihm
-metier
-dao
-entite
-ws

整个项目编译,mvn:install没有问题。

问题出在 ws 模块上:我的 CXF 配置可能有问题:当我在我的 tomcat (v7) 上部署模块时,我对 WSDL 上的每个操作都有这些警告:

déc. 29, 2015 10:02:56 AM org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean initializeWSDLOperations
AVERTISSEMENT: No method was found for the WSDL operation {http://ws.gesaction.interiale.fr}Authentification.

但是这些操作当然包含在 WSDL 中...这让我抓狂。

配置文件如下:

ws-context.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:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd       
        http://www.springframework.org/schema/context       
        http://www.springframework.org/schema/context/spring-context-4.1.xsd   ">

    <context:component-scan base-package="fr.interiale.gesaction.ws.impl"/>
    <context:annotation-config />  
    <import resource="classpath:metier-context.xml"/>  
    <import resource="cxf-context.xml" />

</beans>

cxf-context.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" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.1.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.1.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">

<!--    <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/> -->

    <jaxws:endpoint 
        id="interialActionSocialAuthentification" 
        implementor="fr.interiale.gesaction.ws.InterialActionSocialAuthentification"
        endpointName="tns:InterialActionSocialAuthentificationPort"
        serviceName="tns:InterialActionSocialAuthentificationService" 
        address="/InterialActionSocialAuthentificationPort"
        xmlns:tns="http://ws.gesaction.interiale.fr"
        wsdlLocation="wsdl/interialactionsocialauthentification.wsdl">
    </jaxws:endpoint>

</beans>

现在是 WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://ws.gesaction.interiale.fr" 
    name="interialactionsocialauthentification"
    targetNamespace="http://ws.gesaction.interiale.fr" 
    >

    <wsdl:types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema">
            <import namespace="http://ws.gesaction.interiale.fr" schemaLocation="interialactionsocialauthentification_schema1.xsd" />
        </schema>
    </wsdl:types>


    <wsdl:message name="Authentification">
        <wsdl:part name="parameters" element="tns:Authentification"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="AuthentificationResponse">
        <wsdl:part name="parameters" element="tns:AuthentificationResponse"></wsdl:part>
    </wsdl:message>

    <wsdl:message name="remiseANullTokenResponse">
        <wsdl:part name="parameters" element="tns:remiseANullTokenResponse">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="remiseANullToken">
        <wsdl:part name="parameters" element="tns:remiseANullToken">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="AuthentificationParTokenResponse">
        <wsdl:part name="parameters" element="tns:AuthentificationParTokenResponse">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="AuthentificationParToken">
        <wsdl:part name="parameters" element="tns:AuthentificationParToken">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="Exception">
        <wsdl:part name="Exception" element="tns:Exception">
        </wsdl:part>
    </wsdl:message>

    <wsdl:portType name="InterialActionSocialAuthentification">

        <wsdl:operation name="Authentification">
            <wsdl:input name="Authentification" message="tns:Authentification"></wsdl:input>
            <wsdl:output name="AuthentificationResponse" message="tns:AuthentificationResponse"></wsdl:output>
            <wsdl:fault name="Exception" message="tns:Exception"></wsdl:fault>
        </wsdl:operation>

        <wsdl:operation name="remiseANullToken">
            <wsdl:input name="remiseANullToken" message="tns:remiseANullToken">
            </wsdl:input>
            <wsdl:output name="remiseANullTokenResponse" message="tns:remiseANullTokenResponse">
            </wsdl:output>
            <wsdl:fault name="Exception" message="tns:Exception">
            </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="AuthentificationParToken">
            <wsdl:input name="AuthentificationParToken" message="tns:AuthentificationParToken">
            </wsdl:input>
            <wsdl:output name="AuthentificationParTokenResponse"
                message="tns:AuthentificationParTokenResponse">
            </wsdl:output>
            <wsdl:fault name="Exception" message="tns:Exception">
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="InterialActionSocialAuthentificationServiceSoapBinding"
        type="tns:InterialActionSocialAuthentification">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="Authentification">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="Authentification">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="AuthentificationResponse">
                <soap:body use="literal" />
            </wsdl:output>
            <wsdl:fault name="Exception">
                <soap:fault name="Exception" use="literal" />
            </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="AuthentificationParToken">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="AuthentificationParToken">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="AuthentificationParTokenResponse">
                <soap:body use="literal" />
            </wsdl:output>
            <wsdl:fault name="Exception">
                <soap:fault name="Exception" use="literal" />
            </wsdl:fault>
        </wsdl:operation>
        <wsdl:operation name="remiseANullToken">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="remiseANullToken">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="remiseANullTokenResponse">
                <soap:body use="literal" />
            </wsdl:output>
            <wsdl:fault name="Exception">
                <soap:fault name="Exception" use="literal" />
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="InterialActionSocialAuthentificationService">
        <wsdl:port name="InterialActionSocialAuthentificationPort"
            binding="tns:InterialActionSocialAuthentificationServiceSoapBinding">
            <soap:address location="http://localhost:8080/gesAction-ws" />
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

WSDL 中引用的 XSD:

<xs:schema 
    xmlns:tns="http://ws.gesaction.interiale.fr" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    attributeFormDefault="unqualified" 
    elementFormDefault="unqualified" 
    targetNamespace="http://ws.gesaction.interiale.fr">

  <xs:element name="Authentification" type="tns:Authentification"/>
  <xs:element name="AuthentificationParToken" type="tns:AuthentificationParToken"/>
  <xs:element name="AuthentificationParTokenResponse" type="tns:AuthentificationParTokenResponse"/>
  <xs:element name="AuthentificationResponse" type="tns:AuthentificationResponse"/>
  <xs:element name="remiseANullToken" type="tns:remiseANullToken"/>
  <xs:element name="remiseANullTokenResponse" type="tns:remiseANullTokenResponse"/>
  <xs:element name="utilisateur" type="tns:utilisateur"/>

  <xs:complexType name="Authentification">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
      <xs:element minOccurs="0" name="arg1" type="xs:string"/>
      <xs:element minOccurs="0" name="arg2" type="xs:boolean"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AuthentificationResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:utilisateur"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="utilisateur">
    <xs:sequence>
      <xs:element minOccurs="0" name="idutilisateur" type="xs:decimal"/>
      <xs:element minOccurs="0" name="nom" type="xs:string"/>
      <xs:element minOccurs="0" name="prenom" type="xs:string"/>
      <xs:element minOccurs="0" name="login" type="xs:string"/>
      <xs:element minOccurs="0" name="mdp" type="xs:string"/>
      <xs:element minOccurs="0" name="profil" type="xs:string"/>
      <xs:element minOccurs="0" name="token" type="xs:string"/>
      <xs:element minOccurs="0" name="tokenTimestamp" type="tns:timestamp"/>
      <xs:element minOccurs="0" name="maritalStatus" type="xs:string"/>
      <xs:element minOccurs="0" name="profilSummary" type="xs:string"/>
      <xs:element minOccurs="0" name="birthday" type="xs:dateTime"/>
      <xs:element minOccurs="0" name="ville" type="xs:string"/>
      <xs:element minOccurs="0" name="codePostal" type="xs:string"/>
      <xs:element minOccurs="0" name="mobileNumber" type="xs:string"/>
      <xs:element minOccurs="0" name="email" type="xs:string"/>
      <xs:element minOccurs="0" name="civilite" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="timestamp">
    <xs:sequence>
      <xs:element name="nanos" type="xs:int"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="remiseANullToken">
    <xs:sequence>
      <xs:element name="arg0" type="xs:int"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="remiseANullTokenResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:boolean"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AuthentificationParToken">
    <xs:sequence>
      <xs:element minOccurs="0" name="arg0" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AuthentificationParTokenResponse">
    <xs:sequence>
      <xs:element minOccurs="0" name="return" type="tns:utilisateur"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="Exception" type="tns:Exception"/>
  <xs:complexType name="Exception">
    <xs:sequence>
      <xs:element minOccurs="0" name="message" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

我可以正确部署它并使用 SOAP GUI 工具发送一些 SOAP 请求。

但是我不能让它工作:'(

如果需要任何帮助理解的东西,我会用它来编辑我的post。

非常感谢您的帮助。

您需要使用 "Authentification" 映射端点方法,以便 spring 将在 soap 客户端请求时检测并执行它。

在spring中我们按如下方式进行:-

@端点
public class 我的端点{

@PayloadRoot(localPart="Authentification", namespace=SOME_TARGET_NAMESPACE)
public @ResponsePayload MyResponse myMethod(@RequestPayload MyRequest request){

}

}

在spring-config中添加<context:component-scan base-package="package-name" />。xml

事实上我错过了 CXF 代码生成......这部分生成带有所有必需注释的服务接口(@WebService 等......)