C#Web服务参考中的CData和Escape字符

时间:2014-06-16 14:56:22

标签: c# vb.net web-services soap cdata

我正在尝试与一些第三方中间件Java Web服务进行通信, 我们使用字符串通过Soap发送XML,这会导致自动生成的可视绑定用转义字符替换某些字符

"<" / ">" / "
" 

由于某种原因,Java Webservice(soap主机)无法处理。

因此,转义非法字符的替代方法是将所有内容包装在

"<![CDATA[...]]", 

然而,这并不会阻止自动生成的绑定转义所有特殊

(<, >, \) 

字符。

所以结果是这样的

enter image description here

有人有任何建议如何解决这个问题吗?

EndpointAddress = New System.ServiceModel.EndpointAddress(WebserviceReleaseURL)
serviceBinding = New System.ServiceModel.BasicHttpBinding()
serviceBinding.ReceiveTimeout = New TimeSpan(0, 0, 120)

serviceBinding.Security.Mode = BasicHttpSecurityMode.Transport
serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic

serviceBinding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Mtom

serviceBinding.ProxyAddress = New Uri("http://127.0.0.1:8888")
serviceBinding.BypassProxyOnLocal = False
serviceBinding.UseDefaultWebProxy = False

c = New VU.receive_PortTypeClient(serviceBinding, endpointAddress)

c.ClientCredentials.UserName.UserName = WebserviceReleaseUsername
c.ClientCredentials.UserName.Password = WebserviceReleasePassword
c.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation

c.Open()

Dim ServiceInput As New VU.receiveIn
Dim ServiceOutput As New VU.receiveOut

Dim cdata As New XCData(data)

ServiceInput.xmlString = cdata.ToString();
ServiceOutput = c.receive(ServiceInput)

0 个答案:

没有答案