web services 返回object[]类型的值,如何得到这个方法返回的xml文件
我用asp.net调用一个AXIS编写的web services ,这个web services中的方法返回一个object[]类型的值,我如何能够得到这个方法传过来的xml文件。 --------------------编程问答-------------------- 我用asp.net调用一个AXIS编写的web services ,这个web services中的方法返回一个object[]类型的值,通过网站链接可以看到的这个方法的xml文件,我如何能够完整的得到这个xml文件--------------------编程问答-------------------- 将参数序列化看看 --------------------编程问答-------------------- 直接用获取网页文件的办法就可以.
WEBCLIENT.DOWNLOADSTRING --------------------编程问答-------------------- xmldocument获取 --------------------编程问答-------------------- 用xmldocument获取,或用WebClient.DownloadString (String) 下载指定资源. --------------------编程问答-------------------- 你只要在程序中顺利得到这个返回值,然后foreach一下不就行了? --------------------编程问答-------------------- 已经能够得到返回值,拼装XML也可以啊 --------------------编程问答-------------------- 我看最好使! --------------------编程问答-------------------- 选择这个我 --------------------编程问答-------------------- 找个可以监视http报文的工具看看
比如很简单的tcpmon,好像才几十KB。 --------------------编程问答-------------------- 通过SOAP的方式调用 --------------------编程问答-------------------- 我贴代码 LZ把帖子节了吧.
就是通过XMLHTTPREQUEST对象调用的 --------------------编程问答-------------------- using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using FormChild;
9using MSXML2;
10
11namespace FormParent
12{
13 public partial class Form1 : Form
14 {
15 public Form1()
16 {
17 InitializeComponent();
18 }
19
20 private void Form1_Load(object sender, EventArgs e)
21 {
22
23 }
24
25 private void btnGet_Click(object sender, EventArgs e)
26 {
27 MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();
28 xmlhttp.open("GET", "http://localhost:1323/WebSite6/Service.asmx/SayHelloTo?Name=Zach", false, null, null);
29 xmlhttp.send("");
30 MSXML2.XMLDocument dom = new XMLDocument();
31 Byte[] b = (Byte[])xmlhttp.responseBody;
32
33 string s = System.Text.ASCIIEncoding.UTF8.GetString(b, 0, b.Length);
34 MessageBox.Show(s);
35 }
36
37 private void btnPost_Click(object sender, EventArgs e)
38 {
39 string strData = @"<?xml version='1.0' encoding='utf-8'?>
40 <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
41 <soap:Body>
42 <SayHelloTo xmlns='http://tempuri.org/'>
43 <Name>Zach</Name>
44 </SayHelloTo>
45 </soap:Body>
46 </soap:Envelope>";
47 strData = strData.Replace("'", "\"");
48
49 MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();
50 xmlhttp.open("POST", "http://localhost:1323/WebSite6/Service.asmx", false, null, null);
51 xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
52 xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/SayHelloTo");//Please add it,or you will get 500 error.
53 xmlhttp.send(strData);
54
55 Byte[] b = (Byte[])xmlhttp.responseBody;
56 string s = System.Text.ASCIIEncoding.UTF8.GetString(b, 0, b.Length);;
57 MessageBox.Show(s);
58
59 }
60
61 }
62} --------------------编程问答-------------------- mark --------------------编程问答-------------------- 帮顶 --------------------编程问答-------------------- 帮顶 --------------------编程问答-------------------- 用xmldocument获取,或用WebClient.DownloadString (String) 这个应该可以
补充:.NET技术 , Web Services