다음은 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' 호출을하고 당신은 –