0
以下は私のXMLリクエストです。私は初心者です。xmlns = ""が不要に追加される
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.juniper.es/webservice/2007/">
<soapenv:Header/>
<soapenv:Body>
<HotelAvail>
<HotelAvailRQ Version="1.1" Language="en">
<Login Email="[email protected]" Password="pass" />
<Paxes>
<Pax IdPax="1">
<Age>8</Age>
</Pax>
</Paxes>
<HotelRequest>
<SearchSegmentsHotels>
<SearchSegmentHotels Start="2013-08-20" End="2013-08-22" DestinationZone="1953"/>
<CountryOfResidence>ES</CountryOfResidence>
<Boards>
<Board Type="AD"/>
</Boards>
</SearchSegmentsHotels>
<RelPaxesDist>
<RelPaxDist>
<RelPaxes>
<RelPax IdPax="1"/>
</RelPaxes>
</RelPaxDist>
</HotelRequest>
<AdvancedOptions>
<ShowHotelInfo>true</ShowHotelInfo>
</AdvancedOptions>
</HotelAvailRQ>
</HotelAvail>
</soapenv:Body>
</soapenv:Envelope>
私はこのためにC#要求を作成しようとしていますが、私はxmlns = ""私はしたくないです。
//Declaration
const string SOAPENV_NS = "http://schemas.xmlsoap.org/soap/envelope/";
const string WKSP_NS = "http://www.juniper.es/webservice/2007/";
XmlDeclaration xmlDeclaration = XMLDoc1.CreateXmlDeclaration("1.0", "utf-16", null);
//root
XMLsoapenv = XMLDoc1.CreateElement("soapenv", "Envelope", SOAPENV_NS);
XMLsoapenv.SetAttribute("xmlns:soapenv", SOAPENV_NS);
XMLsoapenv.SetAttribute("xmlns", WKSP_NS);
//XMLDoc1.AppendChild(XMLsoapenv);
//header
XMLsoapenvHeader = XMLDoc1.CreateElement("soapenv", "Header", SOAPENV_NS);
XMLsoapenv.AppendChild(XMLsoapenvHeader);
XMLsoapenvBody = XMLDoc1.CreateElement("soapenv", "Body", SOAPENV_NS);
XMLsoapenv.AppendChild(XMLsoapenvBody);
//XMLDoc1.AppendChild(XMLsoapenv);
XMLHotelAvail = XMLDoc1.CreateElement("HotelAvail");
XMLHotelAvailRQ = XMLDoc1.CreateElement("HotelAvailRQ");
XMLHotelAvailRQ.SetAttribute("Version", "1.1");
XMLHotelAvailRQ.SetAttribute("Language", language1);
XMLLogin = XMLDoc1.CreateElement("Login");
XMLLogin.SetAttribute("Email", email);
XMLLogin.SetAttribute("Password", password);
XMLHotelAvailRQ.AppendChild(XMLLogin);
XMLPaxes = XMLDoc1.CreateElement("Paxes");
XMLPaxFirstChild = XMLDoc1.CreateElement("Pax");
XMLPaxFirstChild.SetAttribute("IdPax", "1");
XMLPaxFirstChild.SetAttribute("Age", searchCriteria.FirstChild);
XMLPaxes.AppendChild(XMLPaxFirstChild);
XMLHotelAvailRQ.AppendChild(XMLPaxes);
XMLHotelRequest = XMLDoc1.CreateElement("HotelRequest");
XMLSearchSegmentsHotels = XMLDoc1.CreateElement("SearchSegmentsHotels");
XMLSearchSegmentHotels = XMLDoc1.CreateElement("SearchSegmentHotels");
XMLSearchSegmentHotels.SetAttribute("Start", searchCriteria.CheckInDate);
XMLSearchSegmentHotels.SetAttribute("End", searchCriteria.CheckOutDate);
XMLSearchSegmentHotels.SetAttribute("DestinationZone", "628");
XMLCountryOfResidence = XMLDoc1.CreateElement("CountryOfResidence", searchCriteria.Country);
XMLSearchSegmentHotels.AppendChild(XMLCountryOfResidence);
XMLSearchSegmentsHotels.AppendChild(XMLSearchSegmentHotels);
XMLHotelRequest.AppendChild(XMLSearchSegmentsHotels);
XMLRelPaxesDist = XMLDoc1.CreateElement("RelPaxesDist");
XMLRelPaxDist = XMLDoc1.CreateElement("RelPaxDist");
XMLRelPaxes = XMLDoc1.CreateElement("RelPaxes");
XMLRelPax = XMLDoc1.CreateElement("RelPax");
XMLRelPax.SetAttribute("IdPax", "1");
XMLRelPaxes.AppendChild(XMLRelPax);
XMLRelPaxDist.AppendChild(XMLRelPaxes);
XMLRelPaxesDist.AppendChild(XMLRelPaxDist);
XMLHotelRequest.AppendChild(XMLRelPaxesDist);
XMLHotelAvailRQ.AppendChild(XMLHotelRequest);
XMLHotelAvail.AppendChild(XMLHotelAvailRQ);
XMLsoapenv.AppendChild(XMLHotelAvail);
//XMLsoapenvBody.AppendChild(XMLHotelAvail);
//XMLsoapenv.AppendChild(XMLsoapenvBody);
XMLDoc1.AppendChild(XMLsoapenv);
私はのxmlnsは=「」追加されないように、私はどこかでそれを読むが、何の使用は私もURLを取得しないようHotelavailタグに「SOAPENV_NS」を与えて試してみました。
ご協力いただければ幸いです。
ようこそスタックオーバーフロー。これを[mcve]に減らしてください - 問題を表すために*たくさんのXMLやコードは必要ないと確信しています。次にコードを可能な限り読みやすい形で書式設定してください。プレビューを使用して投稿を表示すると、あなたの投稿がどのように見えるかを確認してください。 –
(これはXSLTやxmlhttprequestとは何かが関係しているかどうかは不明です。可能であれば、古いXmlDocument APIではなくLINQ to XMLを使用することを強くお勧めします) –
正しい名前空間を'CreateElement'を呼び出すと、あなたは –