#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2003
    Location
    Washington, D.C.
    Posts
    722
    Rep Power
    30

    SOAP - Sending XML within envelope body


    Greetings-
    I'm trying to trouble shoot a SOAP call in which I'm receiving some vague error output. From what I can tell, it looks like the errors are surrounding the XML within the SOAP body.

    I'm wondering if XML can be passed as a string within the envelope body or if it has be serialized or converted to an object or something like that. I'm using nusoap and have successfully authenticated myself with the server. I have validated the XML document that is to be passed within the envelope againt its XSD and it validates with no errors.

    PHP Code:
    //Go fetch the xml doc and export it as a string
    $doc = new DOMDocument();
    $doc->load("xml_docs/xml_doc_314.xml");
    $xml $doc->saveXML();

    //Build the nusoap envelope
    $env '
    <CreateNewOrder_Method xmlns="KelterAshton.Exchange.PurchaseManager.0958943">
        <SystemUserName>Sysuser140</SystemUserName>
        <CustomerCode>9462</CustomerCode>
        <xml_order>'
    .htmlspecialchars($xml).'</xml_order>
    </CreateNewOrder_Method>'


    XSD:
    PHP Code:
    <s:element name="CreateNewOrder">
        <
    s:complexType>
            <
    s:sequence>
                <
    s:element minOccurs="0" maxOccurs="1" name="SystemUserName" type="s:string" /> 
                <
    s:element minOccurs="0" maxOccurs="1" name="CustomerCode" type="s:string" /> 
                <
    s:element minOccurs="0" maxOccurs="1" name="xml_order">
                    <
    s:complexType mixed="true">
                        <
    s:sequence>
                            <
    s:any /> 
                        </
    s:sequence>
                    </
    s:complexType>
                </
    s:element>
            </
    s:sequence>
        </
    s:complexType>
    </
    s:element
    Last edited by jsbruns; March 4th, 2008 at 09:42 PM.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Why don't you show us the error?

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2003
    Location
    Washington, D.C.
    Posts
    722
    Rep Power
    30
    Here is the SOAP Request, the SOAP Response and SOAP Fault. I have truncated the XML string within the xDoc tag to keep it shorter. Although, as I mentioned, the XML that is sent in the xDoc tag has been validated against its schema.

    PHP Code:
    Request
    POST /order/OrderTest.asmx HTTP/1.0
    Host: ordertest.domain.com
    User-Agent: NuSOAP/0.7.3 (1.114)
    Content-Type: text/xml; charset=ISO-8859-1
    SOAPAction: "KelterAshton.Exchange.PurchaseManager.0958943/CreateNewOrder_Method"
    Content-Length: 1012
    Cookie: ARPT=VVQPWYS198.153.160.137CKQKY; 

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="KelterAshton.Exchange.PurchaseManager.0958943">
        <SOAP-ENV:Header>
            <SessionHeader xmlns="KelterAshton.Exchange.PurchaseManager.0958943">
                <SessionID>21023B75EF174142B720EC5AD5A7570D</SessionID>
            </SessionHeader>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <CreateNewOrder_Method xmlns="KelterAshton.Exchange.PurchaseManager.0958943">
                <SystemUserName>Sysuser140</SystemUserName>
                <CustomerCode>9462</CustomerCode>
                <xDoc>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;/*...XML STRING TRUNCATED...*/</xDoc>
            </CreateNewOrder_Method>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Response
    HTTP/1.1 100 Continue

    HTTP/1.1 500 Internal Server Error
    Cache-Control: private
    Content-Length: 1708
    Content-Type: text/xml; charset=utf-8
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    Date: Wed, 05 Mar 2008 15:46:47 GMT

    <?xml version="1.0" encoding="utf-8"?>
    <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>
            <soap:Fault>
                <faultcode>soap:Client</faultcode>
                <faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---&gt; System.InvalidOperationException: There is an error in XML document (142, 8). ---&gt; System.InvalidOperationException: The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.
                   at System.Xml.XmlNode.AppendChild(XmlNode newChild)
                   at System.Xml.Serialization.XmlSerializationReader.ReadXmlDocument(Boolean wrapped)
                   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read26_Item()
                   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer24.Deserialize(XmlSerializationReader reader)
                   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                   --- End of inner exception stack trace ---
                   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
                   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
                   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
                   --- End of inner exception stack trace ---
                   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
                   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
                  </faultstring>
                  <detail />
            </soap:Fault>
        </soap:Body>
    </soap:Envelope>

    Fault (Expect - The request contains an invalid SOAP body)
    Array
    (
        [faultcode] => soap:Client
        [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (142, 8). ---> System.InvalidOperationException: The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.
       at System.Xml.XmlNode.AppendChild(XmlNode newChild)
       at System.Xml.Serialization.XmlSerializationReader.ReadXmlDocument(Boolean wrapped)
       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read26_Item()
       at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer24.Deserialize(XmlSerializationReader reader)
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       --- End of inner exception stack trace ---
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
       at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
       --- End of inner exception stack trace ---
       at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
       at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
        [detail] => 
    )

IMN logo majestic logo threadwatch logo seochat tools logo