C#调用webservice问题

cuijy02 2013-04-07 06:06:22
客户端通过C#编写调用服务器的接口获取数据,服务器端webservice基于xfire,发布在tomcat6上,当服务部署到本地机测试(WinXP)时,测试没问题,当部署到linux时,获取不到数据。
获取的数据格式为网页源代码,数据量比较大,已经调整客户端bindings如下
<bindings>
<basicHttpBinding>
<binding name="IMServiceHttpBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>

部署到linux后获取数据是报错如下:
System.ServiceModel.CommunicationException: Error in deserializing body of reply
message for operation 'getstr'. End element 'out' from namespace 'http://servic
e.com' expected. Found element 'soap:Envelope' from namespace 'http://schemas.xm
lsoap.org/soap/envelope/'. Line 1, position 152021. ---> System.Xml.XmlException
: End element 'out' from namespace 'http://service.com' expected. Found element
'soap:Envelope' from namespace 'http://schemas.xmlsoap.org/soap/envelope/'. Line
1, position 152021.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader
, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowEndElementExpected(XmlDictionaryReader
reader, String localName, String ns)
at System.Xml.XmlBaseReader.ReadEndElement()
at System.Xml.XmlBaseReader.ReadElementContentAsString()
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.PartInfo.ReadVa
lue(XmlDictionaryReader reader)
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializePara
meter(XmlDictionaryReader reader, PartInfo part)
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeResp
onse(XmlDictionaryReader reader, Object[] parameters)
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRepl
y(Message message, Object[] parameters)
--- End of inner exception stack trace ---

Server stack trace:
at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRepl
y(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc&
rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRunt
ime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
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 BigStrtest.ServiceReference1.IMServicePortType.getstr()
at BigStrtest.ServiceReference1.MServicePortTypeClient.getstr() in E:\VsProje
cts\BigStrtest\BigStrtest\Service References\ServiceReference1\Reference.cs:line
1354
at BigStrtest.Program.Main(String[] args) in E:\VsProjects\BigStrtest\BigStrt

各位帮忙看下是怎么回事
...全文
124 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qldsrx 2013-04-07
  • 打赏
  • 举报
回复
命名空间错误,对于跨平台调用,建议你使用webHttpBinding,然后修改格式为Json,那样可以避免很多错误的可能,而且Json的数据量比xml小得多。

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧