Google AppEngine上的SOAP

时间:2014-02-03 14:13:01

标签: web-services google-app-engine soap

我正在尝试在GAE中开发Java SOAP客户端。它正在开发(localhost)而非生产(appspot)。 *构建路径中没有添加jar文件。

例外:

com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection <init>: Unable to make javax.xml.ws.wsaddressing.W3CEndpointReference.address accessible.
java.lang.SecurityException: java.lang.IllegalAccessException: Reflection is not allowed on private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
    at com.google.appengine.runtime.Request.process-eae87f47efed913a(Request.java)
    at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.<init>(Accessor.java:243)
    at com.sun.xml.bind.AccessorFactoryImpl.createFieldAccessor(AccessorFactoryImpl.java:66)
    at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.createFieldSeed(RuntimeClassInfoImpl.java:252)
    at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.createFieldSeed(RuntimeClassInfoImpl.java:81)
    at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.findFieldProperties(ClassInfoImpl.java:405)
    at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:308)
    at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:176)
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:243)
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:100)
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:95)
    at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
    at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:330)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
    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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:253)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:453)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:220)
    at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:218)
    at java.security.AccessController.doPrivileged(AccessController.java:34)
    at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:217)
    at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:88)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:370)
    at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:49)
    at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:134)
    at javax.xml.ws.spi.Provider.provider(Provider.java:127)
    at javax.xml.ws.Service.<init>(Service.java:77)
    at jbilling.ApiServiceService.<init>(ApiServiceService.java:51)
    at com.soap.client.SOAPCXFClientServlet.doGet(SOAPCXFClientServlet.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.IllegalAccessException: Reflection is not allowed on private javax.xml.ws.wsaddressing.W3CEndpointReference$Address javax.xml.ws.wsaddressing.W3CEndpointReference.address
    ... 70 more

ApiServiceService.java:

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

public class ApiServiceService extends Service {
    public ApiServiceService() {
     /*ApiServiceService.java:51*/   super(new URL("http://demowebsit.com/api?wsdl"), new QName("http://demowebsit.com/", "ApiServiceService"));
    }
}

大多数开发人员在部署到生产环境时都面临同样的问题:

https://groups.google.com/forum/#!topic/adwords-api/ciSRh-74rAU https://code.google.com/p/googleappengine/issues/detail?id=4910

但在我的情况下,除了JRE,我没有使用任何JARS。

1 个答案:

答案 0 :(得分:1)

挖洞后我知道gae在jax-ws包里找到了一些白名单课。

原因:

javax.xml.ws.Service在内部调用javax.xml.ws.spi.Provider.provide()方法。因为它将使用com.sun.xml.internal.ws.spi.ProviderImpl类从FactoryFinder创建一个Provider变量。但是在gae中,ProviderImpl并未列入白名单,因此我们无法使用jax-ws创建webService客户端。

解决方案:

Apache Axis正在使用jaxrpc,它与gae兼容。使用apache轴从wsdl生成WebService将解决此问题。