locked
web service data type RRS feed

  • Question

  • User-583959464 posted

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
        <soap:Body>
            <RequestData xmlns="http://tempuri.org/">
                <ID></ID>
                <Reference>TEST0222</Reference>
                <DetailsObject>
                    <![CDATA[
    <DetailsObject>
        <A1>Party</A1>
        <CustomerType>P</CustomerType>
        <Gender>M</Gender>
        <Customers>
            <Name>Amy</Name>
      <Name>Billy</Name>
        </Customers>
        <NativeNames>
            <NativeName/>
        </NativeNames>
        <Countries>
            <Country>BANGLADESH</Country>
        </Countries>
    </DetailsObject>
                    ]]>
                </DetailsObject>
       

    in DetailsObject field, there is <Countries>, which may contain 1 or multiple <Country> element inside <Countries> field.

    how can i know the data of <DetailsObject> and data type of <Countries> in <DetailsObject> in document.

    Monday, February 22, 2021 8:21 AM

All replies

  • User1535942433 posted

    Hi 20141113,

    According to your description, I suggest you could refer to the following code to parse SOAP format xml file.

    string xml = Server.MapPath("SOAPFile.xml");
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(xml);
                XmlNamespaceManager xnm = new XmlNamespaceManager(xmldoc.NameTable);
                xnm.AddNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
                xnm.AddNamespace("Mo", "http://www.monternet.com/dsmp/schemas/");
    
    
    
    
                XmlNodeList lst = xmldoc.SelectNodes("//SOAP-ENV:Header/Mo:TransactionID", xnm);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < lst.Count; i++)
                {
                    XmlNode node = lst[i];
                    XmlElement ele = (XmlElement)node;
                    sb.AppendLine(ele.Name + ":" + ele.InnerText);
                    sb.AppendLine("<br />");
                }

    More details,you could refer to below article:

    https://forums.asp.net/t/2067034.aspx?How+do+i+parse+SOAP+formed+XML

    Best regards,

    Yijing Sun

    Tuesday, February 23, 2021 3:54 AM