Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm using some web services in my project and I'm having problems when I tried to get the result (Soap response). The response is like that:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/>
<env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><realizarPeticionPublicacionResponse xmlns="http://mywebserviceURL/v79">
<realizarPeticionPublicacion xmlns="">
<![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?><peticion_publicacionOSBUS_resultado>
<codigo_error>00451</codigo_error>
<descripcion_error>
Error al realizar la validacion del xml contra XMLBean: [error: decimal: Invalid decimal value: unexpected char '44']
</descripcion_error>
</peticion_publicacionOSBUS_resultado>]]>
</realizarPeticionPublicacion>
</realizarPeticionPublicacionResponse>
</env:Body></soapenv:Envelope>


I want to read the code error (codigo_error) and the description (description_error). I have tried the below code but I'm not able to get CDATA content, and the code_error and description tags.

Anyone can give me a clue? I have tried several things, but I'm not able..

Thanks in advance!
Marga

What I have tried:

<pre lang="vb">

Dim Response As System.Net.HttpWebResponse
Response = hwrequest.GetResponse
Dim DataStream As Stream
Dim Reader As StreamReader
DataStream = Response.GetResponseStream()
Reader = New StreamReader(DataStream)
Dim SD2Request As String = Reader.ReadToEnd()

Dim xmlDoc As New System.Xml.XmlDocument
xmlDoc.LoadXml(SD2Request)

Dim xmlnsManager As XmlNamespaceManager = New System.Xml.XmlNamespaceManager(xmlDoc.NameTable)
xmlnsManager.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
xmlnsManager.AddNamespace("v79", "http://www.ejie.es/webServiceEJB/v79jWar")
xmlnsManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
xmlnsManager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
xmlnsManager.AddNamespace("si", "http://example.com/SystemIntegration")

Dim node As XmlNode = xmlDoc.SelectSingleNode("/soapenv:Envelope/soapenv:Body/v79:realizarPeticionPublicacionOSBUSResponse/realizarPeticionPublicacionOSBUSResult", xmlnsManager)
Posted
Comments
Richard Deeming 30-Aug-18 9:16am    
v79:realizarPeticionPublicacionOSBUSResponse/realizarPeticionPublicacionOSBUSResult

<realizarPeticionPublicacionResponse xmlns="http://mywebserviceURL/v79"><realizarPeticionPublicacion xmlns="">

The node names in your sample response don't match the node names in your XPath query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900