C#使用WinForms在SOAP服务器中编辑数据 [英] C# Editing data in SOAP server using WinForms

查看:94
本文介绍了C#使用WinForms在SOAP服务器中编辑数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一台使用SOAP技术的服务器.它包含表格和e.t.c.我也有一个应用程序,可以查找和替换文件中的文本(XML文件中)并将更改保存在新文件中.因此,我需要使用应用程序调用服务器,并以XML格式替换文本并将其保存在PC中.
这是同一程序和源的链接.不同之处在于我的程序还有一个按钮,用于调用服务器.这是我的版本代码的一部分:

Hello,

I have a server which is using a SOAP technology. It contains of forms and e.t.c. Also I have an application which find and replace text in files (in XML files) and save changes in new file. So, I need to call my server using application and replace the text in XML form and save it in my PC.
Here is the link of the same program+source. The difference is that my program has one more button, which is using to call server. This is code''s part of my version:

private void button1_Click(object sender, EventArgs e)    
{                                                                                           Services.SAPUserInfo myObj = new MassFindAndReplace.Services.SAPUserInfo();        Services.Service s = new Services.Service(); 
            myObj = s.SAPgetUserInfoAll("2500036077");  }



这是XML的一部分:



Here is a part of XML:

<my:lg_code xmlns:my="#unknown">2500036077</my:lg_code>



例如,我的程序将找到"2500036077",并将其替换为另一个字符串,并将文档保存在我的PC中.我将Web参考添加到我的获胜表格中,并将Intranet的网址粘贴到该表格中.因此,现在我已连接到服务器.但是我不明白如何在程序中提供来自服务器的数据?
我是Web服务和C#的初学者,请帮助解决此问题.谢谢.



For example, my program will find "2500036077" and will replace it to another string and will save the document in my pc. I added the web reference to my win form, and pasted the url of my intranet to it. So, now I am connected to server. But I don''t understand how can I provide a data from server with my program?
I am a beginner in web services and C#, please help with this problem. Thank You.

推荐答案

引用Web服务时,您无需解析XML,将通过生成的代理/客户端为您创建对象.课.

然后,您将拥有一个.NET对象,您可以修改.NET对象的值.

如果需要,可以使用 XmlSerializer 将其另存为XML. [^ ] .这是一个很好的文档,有很多说明和示例.

有了对象,您就可以进行属性分配,而不是搜索和替换.

确实应该有任何直接解析/编辑XML的需求(除非这里没有列出您的要求). SOAP并不是人类要使用的东西.

干杯.
When you reference a web service you don''t need to parse the XML, the objects will be created for you through the generated proxy/client class.

You will then have a .NET object that you can modify the values of.

If you want, you can then save it out as XML using XmlSerializer[^]. This is a good doc with lots of explanation and good examples.

With the object in hand, you can then just do property assignment instead of search and replace.

There really should be any need to parse/edit the XML directly (unless there''s a requirement here you''ve not yet listed). SOAP isn''t meant to be something used by humans.

Cheers.


这篇关于C#使用WinForms在SOAP服务器中编辑数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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