none
Looking for IXPathNavigable sample for WCFservice to receive and send XMLDocument. RRS feed

  • Question

  • I am looking for sample for wcf service  and client that sends and receives XMLDocument using IXPathNavigable

    Wednesday, April 6, 2016 2:33 PM

Answers

  • "How to sends and receives XMLDocument using IXPathNavigable in WCF Service"

    Huh? All you are supposed to be doing is sending primitive type string data in XML format between the WCF client and service. Then you load the string XML data into a XML Document and do what you want.

    Saturday, April 9, 2016 12:16 AM
  • Hello,

    For example I have this product.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <products>
      <product id="p1">
        <name>Test1</name>
        <country>EN1</country>
      </product>
      <product id="p2">
        <name>Test2</name>
        <country>EN2</country>
      </product>
    </products>
    We can get the product information by using the XMLDocument and XPathNavigator as following:
    XmlDocument doc = new XmlDocument();
    doc.Load("xml file name");
    XPathNavigator nav = doc.CreateNavigator();
    foreach (XPathNavigator product in nav.Select("products/product"))
     {
        string id = product.SelectSingleNode("@id").Value;
        string name = product.SelectSingleNode("name").Value;
        string country= product.SelectSingleNode("country").Value;
     }

    After that you may need to put the above code inside a OperationContract in WCF Service, in this way the client can call the WCF services to get the product information.
    For more information, please check:
    #Walkthrough: Creating and Accessing WCF Services:
    https://msdn.microsoft.com/en-us/library/bb386386.aspx .
    Besides, if you are looking for the whole sample code, I will recommend you submit your sample request on this website:
    https://code.msdn.microsoft.com/windowsapps/site/requests .

    Thanks for your understanding.

    Best regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.







    Friday, April 8, 2016 4:42 AM
    Moderator

All replies

  • Hello,

    For example I have this product.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <products>
      <product id="p1">
        <name>Test1</name>
        <country>EN1</country>
      </product>
      <product id="p2">
        <name>Test2</name>
        <country>EN2</country>
      </product>
    </products>
    We can get the product information by using the XMLDocument and XPathNavigator as following:
    XmlDocument doc = new XmlDocument();
    doc.Load("xml file name");
    XPathNavigator nav = doc.CreateNavigator();
    foreach (XPathNavigator product in nav.Select("products/product"))
     {
        string id = product.SelectSingleNode("@id").Value;
        string name = product.SelectSingleNode("name").Value;
        string country= product.SelectSingleNode("country").Value;
     }

    After that you may need to put the above code inside a OperationContract in WCF Service, in this way the client can call the WCF services to get the product information.
    For more information, please check:
    #Walkthrough: Creating and Accessing WCF Services:
    https://msdn.microsoft.com/en-us/library/bb386386.aspx .
    Besides, if you are looking for the whole sample code, I will recommend you submit your sample request on this website:
    https://code.msdn.microsoft.com/windowsapps/site/requests .

    Thanks for your understanding.

    Best regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.







    Friday, April 8, 2016 4:42 AM
    Moderator
  • Thanks Amy for the sample to show how to use IXPathNavigable .

    This information is available but what is not available is

    "How to sends and receives XMLDocument using IXPathNavigable in WCF Service"

    Fxcop shows the suggestion to use IXPathNavigable  but there is no sample that describes how to do it.

    I would appreciate if you an emaiL either FXcop team

    or MS internal team  (WCF team) to help me in resolve this issue  Your help is highly appreciated.

    This would not only help me but all the developers who are looking for this resolution.

    Friday, April 8, 2016 1:25 PM
  • "How to sends and receives XMLDocument using IXPathNavigable in WCF Service"

    Huh? All you are supposed to be doing is sending primitive type string data in XML format between the WCF client and service. Then you load the string XML data into a XML Document and do what you want.

    Saturday, April 9, 2016 12:16 AM
  • Hi Nishant,

    I would appreciate if you an emaiL either FXcop team

    or MS internal team  (WCF team) to help me in resolve this issue  Your help is highly appreciated.

    This would not only help me but all the developers who are looking for this resolution.


    If you want a completed code sample to implement your requirement, I will recommend you submit your request in here. I have already included this information in my first reply.

    Thanks for your understanding.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Friday, May 6, 2016 9:07 AM
    Moderator