tags:

views:

392

answers:

1

Hi all, When I try to access a webservice hosted in Tomcat from C# code, I get error message like this.

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 . . .
A: 

We had the same problem. I believe you will find a list of lists somewhere in the wsdl, i.e. an element with maxOccurs=unbounded and type being a sequence of a single element also with maxOccurs=unbounded.

See http://stackoverflow.com/questions/345411/error-serializing-body-problem-calling-fedex-webservice-through-net-3-5 for another case of this.

Possible solutions include modifying the wsdl not use lists of lists (e.g., add a dummy field to the inner type), or as suggested on the other link hand-edit your generated code.

Chuck