使用System.Xml.XmlDocument。 [英] working with System.Xml.XmlDocument.

查看:57
本文介绍了使用System.Xml.XmlDocument。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



你好,

我正在用java编写的web服务调用web方法。

我需要传递一个xml文件作为webmethod的参数。

因此我使用System.Xml.XmlDocument加载xml文件。

当我构造<的内容的字符串表示时,调用有效br />
xml,然后使用loadxml Xml.XmlDocument的方法。


但是当我通过使用load方法直接将文件加载到System.Xml.XmlDocument

对象时它失败了。


可能是一个windows规格格式添加到xml内容

如果是,我该如何解决?

非常感谢提前

JJ

解决方案

jens Jensen写道:

我正在用java编写的web服务调用web方法。
我需要将一个xml文件作为参数传递给web方法。
因此我使用System.Xml.XmlDocument来加载xml文件。

当我构造一个xml内容的字符串表示然后使用loadxml时,调用有效。 Xml.XmlDocument的方法。

但是当我使用加载方法直接将文件加载到System.Xml.XmlDocument
对象时它失败了。

可能是一个Windows规范格式添加到xml内容
如果是,我该如何解决?




这是不可能的,虽然因为你还没有说出保存文件的内容,所以它可能是



如果你说的是什么会真的有帮助它失败的方式......你可以吗?b $ b提供一个简短但完整的程序(和样本文件)

演示了这个问题吗?


请参阅 http://www.pobox.com/~skeet /csharp/complete.html 了解更多

信息。


Jon

>如果你说它以什么方式失败会真的有帮助...你能

提供一个简短但完整的程序(和样本文件)来证明这个问题吗? />
请参阅 http://www.pobox。 com / ~siget / csharp / complete.html 获取更多信息。

Jon




方法有效:


ProxyClass GetMess = new ProxyClass();


System.Xml.XmlDocument xmlIn = new XmlDocument();


System.Xml.XmlDocument xmlOut = new XmlDocument();


String str;


str ="构建字符串" ;;(将xml打包成字符串)


xmlIn.LoadXml(str);


xmlOut = GetMess.processMessage (xmlIn);



************************** ****************


不起作用的方法:(错误:未设置对象到一个对象的实例

on:xmlOut = GetMess.processMessage(xmlIn);)

ProxyClass GetMess = new ProxyClass();


System.Xml.XmlDocument xmlIn = new XmlDocument();


System.Xml.XmlDocument xmlOut = new XmlDocument();


XmlTextReader reader = new XmlTextReader(" xml file");


xmlIn.Load(reader);


xmlOut = GetMess.processMessage(xmlIn); (通过例外描述

早些时候在这里)


非常感谢


JJ








我正在用java编写的web服务调用web方法。
我需要将一个xml文件作为参数传递给web方法。
因此我使用System.Xml.XmlDocument来加载xml文件。

当我构造一个xml内容的字符串表示然后使用loadxml时,调用有效。 Xml.XmlDocument的方法。

但是当我使用load方法将文件直接加载到System.Xml.XmlDocument
对象时它失败了。




究竟是什么失败了,加载XML,用

XML作为参数调用Web服务?你得到什么错误信息?您的.NET客户端调用Java Web服务和/或Java Web

服务时是否发生错误




>
-


Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/



Hello,
I''m calling a webmethod from a webservice written in java.
I need to pass an xml file as parameter to the webmethod.
I therefore use System.Xml.XmlDocument to load the xml file.
The call works when i construct a string representation of the content of
the xml and then, use the "loadxml" method to of Xml.XmlDocument .

But it fails when i load the file directly into and System.Xml.XmlDocument
objet by using the load method.

could it be that a windows specifiix formating is added to the xml content
and if yes how can i fix it?

Many thanks in advance
JJ

解决方案

jens Jensen wrote:

I''m calling a webmethod from a webservice written in java.
I need to pass an xml file as parameter to the webmethod.
I therefore use System.Xml.XmlDocument to load the xml file.

The call works when i construct a string representation of the content of
the xml and then, use the "loadxml" method to of Xml.XmlDocument .

But it fails when i load the file directly into and System.Xml.XmlDocument
objet by using the load method.

could it be that a windows specifiix formating is added to the xml content
and if yes how can i fix it?



That''s unlikely, although as you haven''t said what saved the file, it''s
possible.

It would really help if you''d say in what way it fails... can you
provide a short but complete program (and sample file) which
demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for more
information.

Jon


> It would really help if you''d say in what way it fails... can you

provide a short but complete program (and sample file) which
demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for more
information.

Jon



Method that works:

ProxyClass GetMess = new ProxyClass();

System.Xml.XmlDocument xmlIn = new XmlDocument();

System.Xml.XmlDocument xmlOut = new XmlDocument();

String str;

str = "build the string";(packing the xml into a string")

xmlIn.LoadXml(str);

xmlOut = GetMess.processMessage(xmlIn);



******************************************

Method that dont work:( error: object not set to the instance of an object
on :xmlOut = GetMess.processMessage(xmlIn);)

ProxyClass GetMess = new ProxyClass();

System.Xml.XmlDocument xmlIn = new XmlDocument();

System.Xml.XmlDocument xmlOut = new XmlDocument();

XmlTextReader reader = new XmlTextReader("xml file");

xmlIn.Load(reader);

xmlOut = GetMess.processMessage(xmlIn); (throughs exception described
earlier here)

Many thanks

JJ







jens Jensen wrote:

I''m calling a webmethod from a webservice written in java.
I need to pass an xml file as parameter to the webmethod.
I therefore use System.Xml.XmlDocument to load the xml file.
The call works when i construct a string representation of the content of
the xml and then, use the "loadxml" method to of Xml.XmlDocument .

But it fails when i load the file directly into and System.Xml.XmlDocument
objet by using the load method.



What exactly fails, loading the XML, calling the web service with the
XML as a parameter? What error message do you get? Does the error happen
in your .NET client calling the Java web service and/or in the Java web
service?


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


这篇关于使用System.Xml.XmlDocument。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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