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

时间:2015-12-29 09:44:58

标签: java web-services soap wsdl cxf

我现在已经为此困难了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>

XSD引用了WSDL:

<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请求。

但我不能这样做:'(

如果有任何需要帮助理解,我会用它编辑我的帖子。

非常感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

您需要使用“身份验证”映射端点方法,以便spring在肥皂客户端请求后检测并执行它。

春天我们这样做: -

@Endpoint
公共课MyEndpoint {

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

}

}

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

答案 1 :(得分:1)

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