Java 创建正在使用的SOAP服务时出错

Java 创建正在使用的SOAP服务时出错,java,soap,playframework,playframework-2.0,Java,Soap,Playframework,Playframework 2.0,我正在尝试使用PLAY框架创建SOAP Web服务,参考了中的示例。当我试图执行示例时,得到了这个错误。请在下面找到我的代码。我不太确定样品有什么问题 错误: ! @75olpeh6j - Internal server error, for (GET) [/service/hello?wsdl] -> play.api.PlayException: Cannot init the Global object[Error creating bean with name 'org.apac

我正在尝试使用PLAY框架创建SOAP Web服务,参考了中的示例。当我试图执行示例时,得到了这个错误。请在下面找到我的代码。我不太确定样品有什么问题

错误:

! @75olpeh6j - Internal server error, for (GET) [/service/hello?wsdl] ->

play.api.PlayException: Cannot init the Global object[Error creating bean with name 'org.apache.cxf.transport.play.CxfController#0' defined in class path resource [cxf.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.transport.play.CxfController$]: Factory method 'getInstance' threw exception; nested exception is java.lang.AbstractMethodError: org.apache.cxf.transport.play.CxfController$.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V]
        at play.api.GlobalSettings$.apply(GlobalSettings.scala:229)
        at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$1.apply(GuiceApplicationBuilder.scala:99)
        at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$1.apply(GuiceApplicationBuilder.scala:99)
        at scala.Option.getOrElse(Option.scala:121)
        at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:99)
        at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
        at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
        at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:168)
        at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:164)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.transport.play.CxfController#0' defined in class path resource [cxf.xml]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.cxf.transport.play.CxfController$]: Factory method 'getInstance' threw exception; nested exception is java.lang.AbstractMethodError: org.apache.cxf.transport.play.CxfController$.play$api$mvc$Results$_setter_$TooManyRequests_$eq(Lplay/api/mvc/Results$Status;)V
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756)
Global.java:

import play.*;
import play.libs.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import play.Application;
import play.GlobalSettings;

public class Global extends GlobalSettings {

    protected ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

    @Override
    public void onStart(Application app) {
        ctx.start();
    }

    @Override
    public void onStop(Application app) {
        ctx.stop();
    }
}
<!-- applicationContext.xml -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
 ">

    <!-- Import Apache CXF configuration and Play! transport plugin. -->
    <import resource="classpath:cxf.xml"/>

            <!-- Define Hello World endpoint. It will be available at http://localhost:9000/service/hello -->
    <jaxws:endpoint name="helloWorld"
                    transportId="http://schemas.xmlsoap.org/soap/http"
                    address="/service/hello"
                    implementor="services.hello.HelloWorldImpl"/>

</beans>
applicationContext.xml:

import play.*;
import play.libs.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import play.Application;
import play.GlobalSettings;

public class Global extends GlobalSettings {

    protected ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

    @Override
    public void onStart(Application app) {
        ctx.start();
    }

    @Override
    public void onStop(Application app) {
        ctx.stop();
    }
}
<!-- applicationContext.xml -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
 http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
 ">

    <!-- Import Apache CXF configuration and Play! transport plugin. -->
    <import resource="classpath:cxf.xml"/>

            <!-- Define Hello World endpoint. It will be available at http://localhost:9000/service/hello -->
    <jaxws:endpoint name="helloWorld"
                    transportId="http://schemas.xmlsoap.org/soap/http"
                    address="/service/hello"
                    implementor="services.hello.HelloWorldImpl"/>

</beans>
plugins.sbt

name := "play-cxf-hello"
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.7"
libraryDependencies += "org.springframework" % "spring-context" % 5.0.1.RELEASE"
libraryDependencies += "eu.imind.play" %% "play-cxf_play24" % "1.2.1"
libraryDependencies += "org.apache.cxf" % "cxf-rt-bindings-soap" % "3.1.7"
libraryDependencies += "org.apache.cxf" % "cxf-rt-frontend-jaxws" % "3.1.7"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
// Comment to get more information during initialization
logLevel := Level.Warn

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

resolvers += Resolver.typesafeRepo("releases")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")

您可以用另一种解决方案(如
scalaxb
、apachexf)替换WSDL生成部分,或者自己用
wsimport
生成所有样板文件。要简化后一个项目,请查看以下项目:。基本上,您只需将
wsimport
的Shell脚本包装成一个构建任务(引用的项目使用SBT,但您可以将其调整为Gradle或Maven),然后安排适当的任务顺序,以便在主业务逻辑之前生成和编译所有样板代码。另外,还可以使您的repo保持整洁。

您可以用另一种解决方案(如
scalaxb
、apachexf)替换WSDL生成部分,或者自己用
wsimport
生成所有样板文件。要简化后一个项目,请查看以下项目:。基本上,您只需将
wsimport
的Shell脚本包装成一个构建任务(引用的项目使用SBT,但您可以将其调整为Gradle或Maven),然后安排适当的任务顺序,以便在主业务逻辑之前生成和编译所有样板代码。另外,还可以保持您的repo整洁。

您的applicationContext.xml说implementor=“services.hello.HelloWorldImpl。您还可以发布实现者代码吗?请参考实现者,我只使用了这个示例。您的applicationContext.xml说implementor=“services.hello.HelloWorldImpl”。你可以发布你的实现者代码吗?请参考实现者,我只使用了那个例子。