C# 我是否可以将简单字符串转换为SOAP消息并发送它?
目前我想知道,在c语言中,是否可以读取字符串并将其转换为Soapmessage并将其发送到服务器进行处理,然后再次将响应转换为字符串?您的代码应该如下所示:C# 我是否可以将简单字符串转换为SOAP消息并发送它?,c#,.net,web-services,soap,service,C#,.net,Web Services,Soap,Service,目前我想知道,在c语言中,是否可以读取字符串并将其转换为Soapmessage并将其发送到服务器进行处理,然后再次将响应转换为字符串?您的代码应该如下所示: var document = Query(user, pass, date, regc); var webRequest = Request(Url, Action, document); var soapResult = Response(webRequest); happiness = soapResult.Deserialize(ou
var document = Query(user, pass, date, regc);
var webRequest = Request(Url, Action, document);
var soapResult = Response(webRequest);
happiness = soapResult.Deserialize(out result);
查询:
internal static string Query(string user, string pass, string date, string regc)
{
var doc = string.Format(@"<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<PersonnelInfo xmlns='http://propartner.ee/'>
<PersonnelInfoRequest xmlns=''>
<username>{0}</username>
<password>{1}</password>
<reg_code>{2}</reg_code>
<date>{3}</date>
<country>est</country>
<language>est</language>
</PersonnelInfoRequest>
</PersonnelInfo>
</s:Body>
</s:Envelope>", user, pass, regc, date);
return doc;
}
答复:
internal static string Response(HttpWebRequest webRequest)
{
var asyncResult = webRequest.BeginGetResponse(null, null);
asyncResult.AsyncWaitHandle.WaitOne();
using (var webResponse = webRequest.EndGetResponse(asyncResult))
{
var responsesteam = webResponse.GetResponseStream();
if (responsesteam == null) return default(string);
using (var rd = new StreamReader(responsesteam))
{
var soapResult = rd.ReadToEnd();
return soapResult;
}
}
}
您的代码应该如下所示:
var document = Query(user, pass, date, regc);
var webRequest = Request(Url, Action, document);
var soapResult = Response(webRequest);
happiness = soapResult.Deserialize(out result);
查询:
internal static string Query(string user, string pass, string date, string regc)
{
var doc = string.Format(@"<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<PersonnelInfo xmlns='http://propartner.ee/'>
<PersonnelInfoRequest xmlns=''>
<username>{0}</username>
<password>{1}</password>
<reg_code>{2}</reg_code>
<date>{3}</date>
<country>est</country>
<language>est</language>
</PersonnelInfoRequest>
</PersonnelInfo>
</s:Body>
</s:Envelope>", user, pass, regc, date);
return doc;
}
答复:
internal static string Response(HttpWebRequest webRequest)
{
var asyncResult = webRequest.BeginGetResponse(null, null);
asyncResult.AsyncWaitHandle.WaitOne();
using (var webResponse = webRequest.EndGetResponse(asyncResult))
{
var responsesteam = webResponse.GetResponseStream();
if (responsesteam == null) return default(string);
using (var rd = new StreamReader(responsesteam))
{
var soapResult = rd.ReadToEnd();
return soapResult;
}
}
}
您的代码应该如下所示:
var document = Query(user, pass, date, regc);
var webRequest = Request(Url, Action, document);
var soapResult = Response(webRequest);
happiness = soapResult.Deserialize(out result);
查询:
internal static string Query(string user, string pass, string date, string regc)
{
var doc = string.Format(@"<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<PersonnelInfo xmlns='http://propartner.ee/'>
<PersonnelInfoRequest xmlns=''>
<username>{0}</username>
<password>{1}</password>
<reg_code>{2}</reg_code>
<date>{3}</date>
<country>est</country>
<language>est</language>
</PersonnelInfoRequest>
</PersonnelInfo>
</s:Body>
</s:Envelope>", user, pass, regc, date);
return doc;
}
答复:
internal static string Response(HttpWebRequest webRequest)
{
var asyncResult = webRequest.BeginGetResponse(null, null);
asyncResult.AsyncWaitHandle.WaitOne();
using (var webResponse = webRequest.EndGetResponse(asyncResult))
{
var responsesteam = webResponse.GetResponseStream();
if (responsesteam == null) return default(string);
using (var rd = new StreamReader(responsesteam))
{
var soapResult = rd.ReadToEnd();
return soapResult;
}
}
}
您的代码应该如下所示:
var document = Query(user, pass, date, regc);
var webRequest = Request(Url, Action, document);
var soapResult = Response(webRequest);
happiness = soapResult.Deserialize(out result);
查询:
internal static string Query(string user, string pass, string date, string regc)
{
var doc = string.Format(@"<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<PersonnelInfo xmlns='http://propartner.ee/'>
<PersonnelInfoRequest xmlns=''>
<username>{0}</username>
<password>{1}</password>
<reg_code>{2}</reg_code>
<date>{3}</date>
<country>est</country>
<language>est</language>
</PersonnelInfoRequest>
</PersonnelInfo>
</s:Body>
</s:Envelope>", user, pass, regc, date);
return doc;
}
答复:
internal static string Response(HttpWebRequest webRequest)
{
var asyncResult = webRequest.BeginGetResponse(null, null);
asyncResult.AsyncWaitHandle.WaitOne();
using (var webResponse = webRequest.EndGetResponse(asyncResult))
{
var responsesteam = webResponse.GetResponseStream();
if (responsesteam == null) return default(string);
using (var rd = new StreamReader(responsesteam))
{
var soapResult = rd.ReadToEnd();
return soapResult;
}
}
}
这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的:这可能是你想要的主题: