接口服务
<OperationContract(Action:="urn:abc")> _
<WebInvoke(BodyStyle:=WebMessageBodyStyle.Bare, Method:="POST")>
Function abc(a as String) As String
方法服务
Public Function abc(a as String) As String Implements IService.abc
'Method
End Function
网页配置
<services>
<service name="Service.IServices">
<endpoint address="" binding="customBinding" contract="Service.IServices" bindingConfiguration="httpSoap12">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<customBinding>
<binding name="httpSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
请求留言
POST http://localhost/Services.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="urn:abc"
Content-Length: 1230
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Error
反序列化操作“abc”的请求消息正文时出错。 OperationFormatter 遇到无效的消息正文。期望找到名称为“abc”且名称空间为“的节点类型“Element”http://tempuri.org/ http://tempuri.org/'。找到节点类型“Element”,名称为“typ:abc”,命名空间为“http://tem.com/ http://tem.com/'
我几天遇到这个错误,我在网上找到了很多解决方案,但仍然面临这个错误。有任何建议或解决方案来解决它吗?我不是还没有行动吗?
我的建议是将字符串转换为字节数组并在每一侧对其进行编码/解码。我厌倦了在我的 Web 服务中遇到这样的奇怪问题,所以现在我的 Web 服务上的每个方法都接受字节数组并返回字节数组。它不会给它们增加任何时间,因为网络服务最终还是会这样做。
请参阅这篇文章的示例网络字符串到字节数组 https://stackoverflow.com/questions/472906/net-string-to-byte-array-c-sharp
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)