XML序列化以及与Java Web服务交互 [英] XML serialization and interacting with a Java web service

查看:54
本文介绍了XML序列化以及与Java Web服务交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在编写一个winforms客户端,需要使用用Java编写的Web服务。基本上,我已经添加了对Web服务的引用,并且已经为我创建了代理类,它似乎工作正常。

现在事实证明在我的winforms项目中我有一个多行TextBox和如果用户输入例如"Social\r\\\
Forum",然后将其序列化为
< RisikoTekst> Social& #xD; \ nForum< / RisikoTekst>
对我来说很好看。字符串中有回车符和换行符,回车符序列化为& #xD;并且新行不会被改变。

现在,我的问题是,Java Web服务做了一些事情,然后它将字符串返回给我:
< RisikoTekst> Social\ nForum< / RisikoTekst>
基本上,它已经删除了回车。现在,我已经在线搜索和搜索了,Java服务的程序员也是如此:-)我们可以找到很多描述这个的文本,但我们不同意如何解释它们。

我认为文本说要删除回车(如 http://www.w3.org /TR/1999/WD-xml-c14n-19991109.html#charescaping )正在讨论当它是空白时删除它,即。当它在XML元素和像这样的东西之间时。我认为如果& #xD;在一个元素内部,即'在元素的值内,然后它不应被删除。

但我找不到一个非暧昧的文章帮助我在这里...当然可以解释为:"Jan,你错了!" :-)

任何帮助?

谢谢!


-
eliasen

解决方案

多行文本框中的文本如何进入XML?您是直接使用XML Serializer还是将文本作为参数发送到Web方法调用?你在使用"添加网络参考"吗?引用Java Web服务?如果是,那么您应该发布问题(或者主持人应该将其移至) http:// social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads

如果您正在使用"添加服务参考",那么您正在使用WCF,以及问题更适合 http://social.msdn.microsoft.com/Forums/en-US/ wcf / threads

否则,请忽略我。 : - )


Hi all

I am writing a winforms client, that needs to consume a web service written in Java. Basically, I have added a reference to the web service, and proxy classes have been created for me, at it seems to work just fine.

Now it turns out that in my winforms project I have a multiline TextBox and if the user enters for instance "Social\r\nForum" then this gets serialized into
<RisikoTekst>Social&#xD;\nForum</RisikoTekst>
which looks fine to me. There is a carriage return and a linefeed in the string, and the carriage return gets serialized into &#xD; and the newline doesn't get altered.

Now, my problem is, that the Java web service does some things and then it returns the string to me like this:
<RisikoTekst>Social\nForum</RisikoTekst>
Basically, it has removed the Carriage Return. Now, I have searched and searched online, and so has the programmer of the Java service :-) We can find plenty of texts describing this, but we disagree on how to interpretate them.

I think that the texts that say to remove the carriage return (like http://www.w3.org/TR/1999/WD-xml-c14n-19991109.html#charescaping) are talking about removing it when it is white space, ie. when it is between XML elements and stuff like this. I think that if the &#xD; is inside an element, ie' inside the value of an element, then it should not be removed.

But I cannot find a non-ambigous article helping me out here... which off course can be interpreted as: "Jan, you are wrong!" :-)

Any help?

Thanks!


-- eliasen

解决方案

How is the text from the multi-line text box getting into the XML? Are you either using the XML Serializer directly or sending the text as a parameter to a web method call? And are you using "Add Web Reference" to refer to the Java web service? If so, then you should post the question (or the moderators should move it to) http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads.

If you're using "Add Service Reference", then you're using WCF, and the question is more appropriate at http://social.msdn.microsoft.com/Forums/en-US/wcf/threads.

Otherwise, please just ignore me. :-)


这篇关于XML序列化以及与Java Web服务交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆