通过c#代码创建wsa soap
我需要在我的c#代码库中使用第三方服务,它需要将节点添加到请求中。(对问题的后续行动) 到目前为止,我能做到的是通过c#代码创建wsa soap,c#,soap,C#,Soap,我需要在我的c#代码库中使用第三方服务,它需要将节点添加到请求中。(对问题的后续行动) 到目前为止,我能做到的是 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Hea
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header xmlns:soap="http://www.w3.org/2005/08/addressing">
<wsa:Action xmlns:wsa="Action">http://tempuri.org/GetDetails</wsa:Action>
<wsa:To xmlns:wsa="To">SAMPLEURL.svc/DP2Svcs11</wsa:To>
</soap:Header>
<soap:Body>
<GetBookingDetails xmlns="http://tempuri.org/">
<UserName>testt</UserName>
<Password>testt</Password>
</GetBookingDetails>
</soap:Body>
</soap:Envelope>
编辑行:
var actionNode = xmlDoc.CreateElement("wsa:Action", "Action");
var actionNodeTo = xmlDoc.CreateElement("wsa:To", "To");
致:
幸运的是,更改为您建议的将导致and节点而不是and节点。对不起,c/p我的意思是var actionNode=xmlDoc.CreateElement(“wsa:Action”);var actionNodeTo=xmlDoc.CreateElement(“wsa:To”);
XmlDocument xmlDoc = new XmlDocument();
inwardStream.Position = 0;
var streamReader = new StreamReader(inwardStream);
var streamWriter = new StreamWriter(outwardStream);
message = streamReader.ReadToEnd();
xmlDoc.LoadXml(message);
var insertNode = (((xmlDoc).LastChild));
var headerNode = xmlDoc.CreateElement("soap", "Header", "http://www.w3.org/2005/08/addressing");
//var actionNode = xmlDoc.CreateElement("wsa", "Action", "http://www.w3.org/2004/12/addressing");
//var actionNodeTo = xmlDoc.CreateElement("wsa", "To", "http://www.w3.org/2004/12/addressing");
var actionNode = xmlDoc.CreateElement("wsa:Action", "Action");
var actionNodeTo = xmlDoc.CreateElement("wsa:To", "To");
actionNode.InnerText = "http://tempuri.org/IFlightBookingService/GetBookingDetails";
actionNodeTo.InnerText = "http://54.251.105.26/GQWCF_FlightEngine/FlightBookingService.svc/DP2Svcs11";
headerNode.AppendChild(actionNode);
headerNode.AppendChild(actionNodeTo);
(((((xmlDoc))).LastChild)).InsertBefore(headerNode, (((((xmlDoc))).LastChild)).FirstChild);
var actionNode = xmlDoc.CreateElement("wsa:Action", "Action");
var actionNodeTo = xmlDoc.CreateElement("wsa:To", "To");
var actionNode = xmlDoc.CreateElement("wsa:Action");
var actionNodeTo = xmlDoc.CreateElement("wsa:To");