2010-12-16 218 views
0

我想從我的grails項目調用C#web服務。編寫該服務的人向我提供了它的URL,我可以通過瀏覽器訪問該URL,並且我也可以訪問WSDL從grails調用asmx C#webservice的問題

我嘗試連接到web服務(該服務需要兩個字符串,使用字符串作爲參數)如下:

public void setClearance(){ 
    //connect to webservice and get clearance info 
    def wsdlURL = "Address/to/webservice/ApplicationServices.asmx?WSDL" 
    def proxy = new WSClient(wsdlURL, this.class.classLoader); 
    proxy.initialize(); 
    String[] userIds = {this.id}; 
    def result = proxy.GetUserInfo("string1", "string2", userIds); 
} 

,我得到以下錯誤:

Dec 16, 2010 1:57:02 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources 
INFO: No cxf.xml configuration file detected, relying on defaults. 
Dec 16, 2010 1:57:05 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory outputDebug 
INFO: Created classes: com.my_site.ArrayOfString, com.my_site.GetUserInfo, com.my_site.GetUserInfoResponse, com.my_site.ObjectFactory 
This id?: 518 
Dec 16, 2010 1:57:09 PM groovyx.net.ws.AbstractCXFWSClient invokeMethod 
INFO: Using SOAP version: 1.1 
Dec 16, 2010 1:57:09 PM groovyx.net.ws.AbstractCXFWSClient invokeMethod 
INFO: available method: {http://mysite.com/}GetUserInfo 
Dec 16, 2010 1:57:09 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept 
WARNING: Interceptor has thrown exception, unwinding now 
org.apache.cxf.interceptor.Fault: Marshalling Error: class [Ljava.lang.String; nor any of its super class is known to th 
is context. 
     at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:160) 
     at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169) 
     at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.jav 
a:105) 
     at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68) 
     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) 
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:478) 
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:308) 
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:260) 
     at groovyx.net.ws.AbstractCXFWSClient.invokeMethod(AbstractCXFWSClient.java:109) 
     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:117) 
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
     at Employee.setClearance(Employee.groovy:110) 
     at Employee$setClearance.call(Unknown Source) 
     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40) 
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) 
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121) 
     at FormattedDocumentController$_closure1.doCall(FormattedDocumentController.groovy:76) 
     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 org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:2 
25) 
     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51) 
     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44) 
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143) 
     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151) 
     at FormattedDocumentController$_closure1.doCall(FormattedDocumentController.groovy) 
     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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88) 
     at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) 
     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058) 
     at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070) 
     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886) 
     at groovy.lang.Closure.call(Closure.java:276) 
     at groovy.lang.Closure.call(Closure.java:271) 
     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleAction(SimpleGrailsControllerHe 
lper.java:372) 
     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.executeAction(SimpleGrailsControllerH 
elper.java:236) 
     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelpe 
r.java:190) 
     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelpe 
r.java:129) 
     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:7 
3) 
     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java 
:48) 
     at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:292) 
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) 
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) 
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 
     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 
     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:292) 
     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:260) 
     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:251) 
     at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:183) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:245) 
     at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:134) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.jsecurity.web.servlet.JSecurityFilter.doFilterInternal(JSecurityFilter.java:384) 
     at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:183) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.jav 
a:67) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:69 
) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) 
     at java.lang.Thread.run(Thread.java:662) 
Caused by: javax.xml.bind.MarshalException 
- with linked exception: 
[javax.xml.bind.JAXBException: class [Ljava.lang.String; 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:244) 
     at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:74) 
     at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:445) 
     at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:139) 
     ... 105 more 
Caused by: javax.xml.bind.JAXBException: class [Ljava.lang.String; 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.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:152) 
     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) 
     ... 109 more 
Caused by: javax.xml.bind.JAXBException: class [Ljava.lang.String; 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) 
     ... 116 more 
Dec 16, 2010 1:57:09 PM groovyx.net.ws.AbstractCXFWSClient invokeMethod 
SEVERE: Could not invoke method. 
. 
. 
. 

什麼是這裏的根本原因?該web服務只是返回一個C#字符串,這是在XML格式..但它不應該爲這個權利嗎?

回答

0

它看起來像你試圖使用Java的數組文本語法在這裏:

String[] userIds = {this.id}; 

這是不是有效的常規。在這種情況下,你正在創建一個閉包。

嘗試:

String[] userIds = [this.id] as String[] 
+1

你並不需要'爲的String []'如果你聲明的類型...'的String []的用戶id = [this.id]'就足夠了:) – 2010-12-17 09:38:02