Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP interacting with .Net (XmlDocument)

Options
  • 14-05-2012 12:40pm
    #1
    Registered Users Posts: 1,657 ✭✭✭


    Is it possible to create a .Net XmlDocument in PHP? I have a PHP site that needs to interact with a web service, written in C# which accepts as its input an XmlDocument object.

    I've tried with the PHP DOMDocument with no luck... BTW my DOMDocument doesn't seem to give any output if I do a print_r of it... (But does if I echo the saveXML() ) ... is this correct?


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I think that all you should need to do is to send a valid XML document, not an actual .Net XmlDocument object. Basically just a string with the valid XML, e.g.
    <?xml version="1.0"?>
    <catalog>
       <book id="bk101">
          <author>Gambardella, Matthew</author>
          <title>XML Developer's Guide</title>
          <genre>Computer</genre>
          <price>44.95</price>
          <publish_date>2000-10-01</publish_date>
          <description>An in-depth look at creating applications 
          with XML.</description>
       </book>
    </catalog>
    
    in it should do. Depending on the service and what it does, it may expect the XML to conform to some particular schema, which the service owners should make available in some way.


  • Registered Users Posts: 2,781 ✭✭✭amen


    An aside I bet you don't even need the xml version tag.

    Have you called the Web Service and looked at wsdl ?
    it should tell you the methods and parameters required.

    H


  • Registered Users Posts: 2,791 ✭✭✭John_Mc


    stevenmu wrote: »
    I think that all you should need to do is to send a valid XML document, not an actual .Net XmlDocument object. Basically just a string with the valid XML, e.g.
    <?xml version="1.0"?>
    <catalog>
       <book id="bk101">
          <author>Gambardella, Matthew</author>
          <title>XML Developer's Guide</title>
          <genre>Computer</genre>
          <price>44.95</price>
          <publish_date>2000-10-01</publish_date>
          <description>An in-depth look at creating applications 
          with XML.</description>
       </book>
    </catalog>
    
    in it should do. Depending on the service and what it does, it may expect the XML to conform to some particular schema, which the service owners should make available in some way.

    +1

    XmlDocument in .Net is just a valid piece of XML which has been successfully parsed into an object in .Net.

    What you really need to do here is identify the schema expected by the service.


  • Registered Users Posts: 1,657 ✭✭✭komodosp


    Had tried that and it didn't work... Didn't expect it to though as .net uses the "LoadXml" method (or something like that) to load Xml into an XmlDocument...

    Anyway, the guy who created the service has agreed to change it to just using a normal object, compatible with an stdClass.


Advertisement