ASMX web service function reads incomplete XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rytlaw
    New Member
    • Feb 2012
    • 1

    ASMX web service function reads incomplete XML

    I wrote a simple web service function using ASMX:

    Code:
    	Public Function processMessage(ByVal Messages as XMLElement) As String	 	
            Dim strS as string
            strS = Messages.outerXML
            Return strS
        End Function
    This should is used to handle SOAP request like the following:
    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:gps-hex-communicator">
       <soap:Header/>
       <soap:Body>
          <processMessage xmlns="urn:gps-hex-communicator">
             <!--Optional:-->
             <Messages>
    		<Message>
    			<DeviceID>5901</DeviceID>
    			<MessageID>201</MessageID>
    		</Message>
    		<Message>
    			<DeviceID>5902</DeviceID>
    			<MessageID>202</MessageID>
    		</Message>
              </Messages>
          </processMessage>
       </soap:Body>
    </soap:Envelope>
    It seems only the first <Message> can be processed. Here's the response:

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <soap:Body>
          <processMessageResponse xmlns="urn:gps-hex-communicator">
             <processMessageResult><![CDATA[<Message xmlns="urn:gps-hex-communicator">
    			<DeviceID>5901</DeviceID>
    			<MessageID>201</MessageID>
    		</Message>]]></processMessageResult>
          </processMessageResponse>
       </soap:Body>
    </soap:Envelope>
    Adding a dummy root in front of <Message> certainly can solve the problem. However the format of request is not allowed to be changed. Is there a simple way to read everything between the <Messages></Messages> tags?
Working...