冒号(“:”)被加密为“ _x003A"从c#传递冒号(:)到java webservice [英] colon (":") is getting encrypted as " _x003A" while passing colon(:) from c# to java webservice
本文介绍了冒号(“:”)被加密为“ _x003A"从c#传递冒号(:)到java webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要在C#.net上使用网络服务(用Java开发)。
在这里我需要将参数名称作为db:hostname传递给c#.net到Java的请求。
Hi All,
I need to consume a webservice(developed in Java) in C#.net.
In this I need to pass the parameter name as db:hostname in request from c#.net to Java.
<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:dev="XXXX/devicemanagement/device" xmlns:com="XXXX/ws/common" xmlns:com1="XXXX/types/common">
<soap:header />
<soap:body>
<dev:adddevicesrequest xmlns:db="XXXX/deviceattribute/basicinfo" xmlns:dauth="XXXX/deviceattribute/authentication" xmlns:dgauth="XXXXX/devicegroupattribute/authentication">
<dev:device>
<dev:attribute>
<com:name>db:HostName</com:name>
<com:stringvalue>192.168.200.101</com:stringvalue>
</dev:attribute>
<dev:attribute>
<com:name>db:DisplayDeviceName</com:name>
<com:stringvalue>d01</com:stringvalue>
</dev:attribute>
<dev:attribute>
<com:name>db:ModelCode</com:name>
<com:stringvalue>ModelCode01</com:stringvalue>
</dev:attribute>
<dev:attribute>
<com:name>db:SerialNumber</com:name>
<com:stringvalue>12301</com:stringvalue>
</dev:attribute>
</dev:device>
</dev:adddevicesrequest>
</soap:body>
</soap:envelope>
<big>When I pass parameter as "db:hostname" from c# to java, it is getting encrypted at java end as "db_x003A_hostname" which means colon (":") is getting converted to " _x003A" at java service. This results an error as "invalid parameter name".</big>
Please help me in resolving this error.
Thanks in advance for your help.
推荐答案
您需要使用UTF8编码。
所有其他都将失败。
You need to use UTF8 Encoding.
All others will fail.
冒号不是元素名称中的有效字符。冒号用于配置命名空间和元素名称。在这里,如果你想要Db,那么你可能需要将它添加为命名空间。
Colon is not a valid character inside a element name. Colon is used to pair the namespace and the element name. Here if you want the Db to go along then you might need to add it as a namespace.
// Serialize the hostname field as an attribute with the given namspace
[XmlAttribute( Namespace ="www.db.com")]
public string hostname;
http://www.diranieh.com/NETSerialization/XMLSerialization.htm#Working%20with%20XML%20Namespaces [<一个href =http://www.diranieh.com/NETSerialization/XMLSerialization.htm#Working%20with%20XML%20Namespacestarget =_ blanktitle =New Window> ^ ]
这篇关于冒号(“:”)被加密为“ _x003A"从c#传递冒号(:)到java webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文