关于发送xml报文请求
发送请求报文 例子:
/****签到: <trn-b2e0001-rq> ****/
<?xml version="1.0" encoding="GB2312"?>
<bocb2e version="100" security="true" lang="chs">
<head>
<termid>E127000000001</termid>
<trnid>20060704001</trnid>
<custid>12345678</custid>
<cusopr>BOC</cusopr>
<trncod>b2e0001</trncod>
</head>
<trans>
<trn-b2e0001-rq>
<b2e0001-rq>
<custdt>20060704091000</custdt>
<oprpwd>88888888</oprpwd>
<ceitinfo>MIIE9AYJKoZIhvcNA……</ceitinfo>
</b2e0001-rq>
</trn-b2e0001-rq>
</trans>
</bocb2e>
请求响应报文
/****:签到响应<trn-b2e0001-rs>****/
<?xml version = "1.0" encoding = "GB2312"?>
<bocb2e version="100" security="true" lang="chs">
<head>
<termid>E127000000001</termid>
<trnid>20060704001</trnid>
<custid>12345678</custid>
<cusopr>BOC</cusopr>
<trncod>b2e0001</trncod>
<token>9TTQALYGH1</token>
</head>
<trans>
<trn-b2e0001-rs>
<status>
<rspcod>B001</rspcod>
<errmsg>OK</errmsg>
</status>
<serverdt>20020615102045</serverdt>
</trn-b2e0001-rs>
</trans>
</bocb2e>
ASP.NET 代码
失败了,返回错误信息 : The remote server returned an error: (500) Internal Server Error.
从代码来说,请问有什么问题?
/****签到: <trn-b2e0001-rq> ****/
<?xml version="1.0" encoding="GB2312"?>
<bocb2e version="100" security="true" lang="chs">
<head>
<termid>E127000000001</termid>
<trnid>20060704001</trnid>
<custid>12345678</custid>
<cusopr>BOC</cusopr>
<trncod>b2e0001</trncod>
</head>
<trans>
<trn-b2e0001-rq>
<b2e0001-rq>
<custdt>20060704091000</custdt>
<oprpwd>88888888</oprpwd>
<ceitinfo>MIIE9AYJKoZIhvcNA……</ceitinfo>
</b2e0001-rq>
</trn-b2e0001-rq>
</trans>
</bocb2e>
请求响应报文
/****:签到响应<trn-b2e0001-rs>****/
<?xml version = "1.0" encoding = "GB2312"?>
<bocb2e version="100" security="true" lang="chs">
<head>
<termid>E127000000001</termid>
<trnid>20060704001</trnid>
<custid>12345678</custid>
<cusopr>BOC</cusopr>
<trncod>b2e0001</trncod>
<token>9TTQALYGH1</token>
</head>
<trans>
<trn-b2e0001-rs>
<status>
<rspcod>B001</rspcod>
<errmsg>OK</errmsg>
</status>
<serverdt>20020615102045</serverdt>
</trn-b2e0001-rs>
</trans>
</bocb2e>
ASP.NET 代码
/// <summary>
///
/// </summary>
/// <param name="xml">XML报文</param>
/// <param name="url">请求url</param>
/// <returns>返回响应的xml</returns>
public string PostXml(string xml, string url)
{
byte[] bytes = Encoding.UTF8.GetBytes(xml);
HttpWebRequest req = null;
try
{
//创建一个HttpWebRequest对象
req = (HttpWebRequest)HttpWebRequest.Create(url);
//设置它提交数据的方式post
req.Method = "POST";
//设置 Content-type HTTP 标头的值
req.ContentType = "text/xml";// "application/x-www-form-urlencoded;charset=GB2312";
req.ContentLength = bytes.Length;
req.KeepAlive = true;
using (Stream requestStream = req.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
if (res.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}", res.StatusCode);
return message;
}
else
{
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
return sr.ReadToEnd();
}
}
catch (Exception ex)
{
return ex.Message;
}
}
失败了,返回错误信息 : The remote server returned an error: (500) Internal Server Error.
从代码来说,请问有什么问题?
...全文
相关推荐
java http 发送xml报文
java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文java http 发送xml报文
java http 发送xml报文(java发送xml报文实例+参数)
java http 发送xml报文(java发送xml报文实例+参数) java http 发送xml报文 java http 发送xml报文(java发送xml报文实例+参数)
java 通过模板生成 xml,发送报文
java 通过模板生成 xml,发送报文
java发送SOAP报文
NULL 博文链接:https://softwarexiang120.iteye.com/blog/2065082
httpclient 客户端发送xml报文到服务器端采用post方式(加密)传递
采用httpclient发送xml报文,httpServer接收报文。两个程序一看就明白可以直接调用执行不在多说。


