简体   繁体   English

从点网客户端调用Java Web服务

[英]Invoking Java webservice from dot net client

When I try to access a webservice hosted in Tomcat from C# code, I get error message like this. 当我尝试从C#代码访问Tomcat中托管的Web服务时,出现了这样的错误消息。

There was an error in serializing body of message searchRepositoriesRequest: '
Unable to generate a temporary class (result=1).
error CS0266: Cannot implicitly convert type 'object' to 'object[]'. An explicit
 conversion exists (are you missing a cast?)
error CS0266: Cannot implicitly convert type 'object' to 'object[]'. An explicit
 conversion exists (are you missing a cast?)
error CS0266: Cannot implicitly convert type 'object' to 'object[]'. An explicit
 conversion exists (are you missing a cast?)
'.  Please see InnerException for more details.

Can some one help me?? 有人能帮我吗?? Please refer the stack trace given below. 请参考下面给出的堆栈跟踪。

Server stack trace:
   at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBo
dy(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDes
cription messageDescription, Object returnValue, Object[] parameters, Boolean is
Request)
   at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(Xm
lDictionaryWriter writer, MessageVersion version, Object[] parameters, Object re
turnValue, Boolean isRequest)
   at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessag
e.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
   at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWri
ter writer)
   at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDict
ionaryWriter writer)
   at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter wr
iter)
   at System.ServiceModel.Channels.Message.WriteMessage(XmlDictionaryWriter writ
er)
   at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message me
ssage, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
   at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.
WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager,
 Int32 messageOffset)
   at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message m
essage)
   at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.SendRequest(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
pan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
e, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at WSTesting2.SBS.SBSQueryService.searchRepositories(searchRepositoriesReques
t request)
   at WSTesting2.SBS.SBSQueryServiceClient.WSTesting2.SBS.SBSQueryService.search
Repositories(searchRepositoriesRequest request) in E:\Tetsngs\WSTesting2\Service
 References\SBS\Reference.cs:line 2253
   at WSTesting2.SBS.SBSQueryServiceClient.searchRepositories(searchRequest arg0
) in E:\Tetsngs\WSTesting2\Service References\SBS\Reference.cs:line 2259
   at WSTesting2.Program.Main(String[] args) in E:\Tetsngs\WSTesting2\Program.cs
:line 66Press any key to continue . . .

We had the same problem. 我们有同样的问题。 I believe you will find a list of lists somewhere in the wsdl, ie an element with maxOccurs=unbounded and type being a sequence of a single element also with maxOccurs=unbounded. 我相信您会在wsdl中的某个地方找到列表列表,即maxOccurs = unbounded的元素,类型是maxOccurs = unbounded的单个元素的序列。

See 'Error serializing body'. 请参见“错误序列化正文”。 Problem calling Fedex webservice through .NET 3.5 for another case of this. 在另一种情况下, 通过.NET 3.5调用Fedex Webservice时出现问题

Possible solutions include modifying the wsdl not use lists of lists (eg, add a dummy field to the inner type), or as suggested on the other link hand-edit your generated code. 可能的解决方案包括修改wsdl不使用列表的列表(例如,向内部类型添加一个虚拟字段),或者按照另一链接上的建议手动编辑生成的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM