0
我有一個使用各種XmlDocument.CreateElement和AppendChild方法調用動態構建的SOAP消息。這個SOAP消息找出來是這樣的:爲了接收SOAP消息,MS MVC控制器的簽名是什麼?
var message="<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">
<SOAP:Body>
<m:EDI
ID=\"ConfigurationName={f0dc2db2-0431-4c31-ba8b-053a33f3899f}\"
Frequency =\"8\" xmlns:m\"http://www.foo/schemas/\">
<Totes><Tote
a=\"\"
b=\"123\"
c=\"Stati\"
d=\"T8b52830b-fe69-4\"
e=\"M0056122648\"
f=\"Route\"
g=\"\"
h=\"1/1/0001 12:00:00 AM\" />
</Totes>
</m:EDI></SOAP:Body></SOAP:Envelope>";
現在,我想張貼此一個MS MVC的行動,但我不知道是幹什麼用的簽名或如何將它張貼。我想這和它的工作,但rawSoapMessage參數的行動是無效:
var messageBytes = Encoding.UTF8.GetBytes(message);
var webRequest = (HttpWebRequest) WebRequest.Create(url);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
webRequest.ContentLength = messageBytes.Count();
using (var s = webRequest.GetRequestStream())
{
s.Write(messageBytes, 0, messageBytes.Length);
s.Close();
}
var webResponse = (HttpWebResponse) webRequest.GetResponse();
這裏是我試圖張貼到控制器動作:
public string ReceiveManifest([FromBody] string rawSoapMessage)
{
return rawSoapMessage
}
刪除「[FromBody]」產生404.
謝謝。
檢查此鏈接希望這回答您的問題 http://stackoverflow.com/questions/2715914/how-to-use-soap-in-asp-net-mvc – ali
好會顯得過它 - 謝謝 – user2566049