首页 > php教程 > php手册 > 正文

.net调用php

WBOY
发布: 2016-06-06 19:42:27
原创
1121 人浏览过

嗯,是用的直接请求,但参数好像无效,返回来总是提示参数为空 //构造soap请求信息 StringBuilder soap = new StringBuilder(); soap.Append("?xml version=\"1.0\" encoding=\"utf-8\"?"); soap.Append("soap-ENV:Envelope xmlns:soap-ENV=\"http://schemas

嗯,是用的直接请求,但参数好像无效,返回来总是提示参数为空

//构造soap请求信息
StringBuilder soap = new StringBuilder();
soap.Append("");
soap.Append("");
soap.Append("");
soap.Append("");//
soap.Append("244767");
soap.Append("
");
soap.Append("");
soap.Append("
");

//发起请求
Uri uri = new Uri("http://xxxxxxxx/index.php?r=yar/tgoods");
WebRequest webRequest = WebRequest.Create(uri);
webRequest.ContentType = "text/xml; charset=utf-8";
webRequest.Method = "POST";
using (Stream requestStream = webRequest.GetRequestStream())
{
byte[] paramBytes = Encoding.UTF8.GetBytes(soap.ToString());
requestStream.Write(paramBytes, 0, paramBytes.Length);
}

HttpWebResponse res;
try
{
res = (HttpWebResponse)webRequest.GetResponse();
}
catch (WebException ex)
{
res = (HttpWebResponse)ex.Response;
}
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
string strHtml = sr.ReadToEnd();

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!