GroovyWS 请求及其任何超类在此上下文中都是已知的

发布于 2024-11-11 13:48:31 字数 7037 浏览 4 评论 0原文

我正在尝试使用 GroovyWS 来使用 SOAP 服务。

执行此操作的 .NET 代码如下所示:

AdminService.SHCredentials creds = new AdminService.SHCredentials();
creds.Username = "Admin";
creds.Password = "123";

AdminService.GetAccountDetailsRequest req = new AdminService.GetAccountDetailsRequest();
req.Username = "user";

AdminService.GetAccountDetailsResponse res = new AdminService.GetAccountDetailsResponse();

res = admin.GetAccountDetails(creds, req);

使用 GroovyWS 并关闭我正在尝试类似方法的示例:

proxy = new WSClient(wsdlUrl, this.class.classLoader, SoapVersion.SOAP_1_2)
proxy.initialize()

def credentials = proxy.create("com.acme.developer.schemas._2_6.SHCredentials")
credentials.username = "Admin"
credentials.password = "123"

def req = proxy.create("com.acme.developer.schemas._2_6.GetAccountDetailsRequest")
req.username = "user"

def res = proxy.create("com.acme.developer.schemas._2_6.GetAccountDetailsResponse")

res = proxy.GetAccountDetails(credentials, req)

但这会导致以下错误消息:

Jun 1, 2011 2:21:09 PM groovyx.net.ws.AbstractCXFWSClient getBindingOperationInfo
WARNING:  Using SOAP version: 1.2
Jun 1, 2011 2:21:09 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now Marshalling Error: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
Jun 1, 2011 2:21:09 PM groovyx.net.ws.AbstractCXFWSClient invokeMethod
SEVERE: Could not invoke method.
org.apache.cxf.interceptor.Fault: Marshalling Error: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:159)
    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleHeaderPart(SoapOutInterceptor.java:227)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:155)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:80)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:469)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
    at groovyx.net.ws.AbstractCXFWSClient.invokeMethod(AbstractCXFWSClient.java:93)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
    at com.acme.soap.client.SoapClient2.getUsers(CopyOfSoapClient.groovy:38)
    at com.acme.soap.client.SoapClient2$getUsers.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.acme.rest.testcases.positive_path.ContactsAdd.test(ContactsAdd.groovy:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:172)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:439)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138)
    ... 36 more
Caused by: javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:246)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:261)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:653)
    at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:149)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:157)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:189)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:323)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:72)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
    ... 39 more
Caused by: javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:594)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:648)
    ... 47 more

我不确定从这里到哪里。该代码似乎没有尝试向服务发送请求。但是,如果我只是发送 proxy.GetAccountDetails() ,消息会发送但不完整。

I'm trying to use GroovyWS to consume a SOAP service.

The .NET code to do this looks like this:

AdminService.SHCredentials creds = new AdminService.SHCredentials();
creds.Username = "Admin";
creds.Password = "123";

AdminService.GetAccountDetailsRequest req = new AdminService.GetAccountDetailsRequest();
req.Username = "user";

AdminService.GetAccountDetailsResponse res = new AdminService.GetAccountDetailsResponse();

res = admin.GetAccountDetails(creds, req);

Using GroovyWS and going off the examples I'm trying a similar approach with:

proxy = new WSClient(wsdlUrl, this.class.classLoader, SoapVersion.SOAP_1_2)
proxy.initialize()

def credentials = proxy.create("com.acme.developer.schemas._2_6.SHCredentials")
credentials.username = "Admin"
credentials.password = "123"

def req = proxy.create("com.acme.developer.schemas._2_6.GetAccountDetailsRequest")
req.username = "user"

def res = proxy.create("com.acme.developer.schemas._2_6.GetAccountDetailsResponse")

res = proxy.GetAccountDetails(credentials, req)

But this leads to the following error message:

Jun 1, 2011 2:21:09 PM groovyx.net.ws.AbstractCXFWSClient getBindingOperationInfo
WARNING:  Using SOAP version: 1.2
Jun 1, 2011 2:21:09 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now Marshalling Error: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
Jun 1, 2011 2:21:09 PM groovyx.net.ws.AbstractCXFWSClient invokeMethod
SEVERE: Could not invoke method.
org.apache.cxf.interceptor.Fault: Marshalling Error: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:159)
    at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleHeaderPart(SoapOutInterceptor.java:227)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:155)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:80)
    at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:469)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
    at groovyx.net.ws.AbstractCXFWSClient.invokeMethod(AbstractCXFWSClient.java:93)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
    at com.acme.soap.client.SoapClient2.getUsers(CopyOfSoapClient.groovy:38)
    at com.acme.soap.client.SoapClient2$getUsers.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.acme.rest.testcases.positive_path.ContactsAdd.test(ContactsAdd.groovy:38)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:172)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:439)
    at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:138)
    ... 36 more
Caused by: javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:246)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:261)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:653)
    at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:149)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:157)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:189)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:316)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:323)
    at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:72)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
    ... 39 more
Caused by: javax.xml.bind.JAXBException: class com.acme.developer.schemas._2_6.GetAccountDetailsRequest nor any of its super class is known to this context.
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:594)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:648)
    ... 47 more

I'm not sure where to go from here. The code does not seem to be attempting to send a request to the service. However, if I just send proxy.GetAccountDetails() the message is sent but incompletely.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文