从 VB.NET Web 服务中的 SOAP 响应中删除 xmlns=""

问题描述 投票:0回答:1
我目前正在使用 vb.net 制作的 Web 服务。问题是我为 WS 响应返回一个 xml 文档,如下所示:

WS Response (注意 mensaje xml 标签)

但是当我从soapUI或Postman调用这个服务时,答案是这样的:

Soap WS Response

它添加了一个 xmlsn="" 我需要删除它,但我不知道如何删除。这是我的代码:

' Load and extract data from the input XML oXMLDocument.LoadXml(Input) sConvenio = GetSetNodeValue(oXMLDocument, "mensaje/encabezado/convenio", "", Nothing) siden01 = Trim(GetSetNodeValue(oXMLDocument, "mensaje/identificador/iden01", "", Nothing)) ' Check the length of a string If Strings.Len(ConectaCompania(sConvenio)) = 36 Then ' Construct a SOAP request sTemp = "<!-- Query -->" sQuery = "<!-- SOAP request construction code -->" ' Send the SOAP request and receive a response sSOAPans = DISnode.Interact(sQuery) oXMLDoc.LoadXml(sSOAPans) ' Process the SOAP response and set values in the response XML If xmlNL.Count = 0 And oXMLDoc.InnerText <> "oRecordset0.00000000" Then ' Extract and set response tags GetSetNodeValue(oXMLDocument, "mensaje/encabezado/codigoRetorno", "000", Nothing) GetSetNodeValue(oXMLDocument, "mensaje/encabezado/mensajeRetorno", "CONSULTA EXITOSA", Nothing) ' Extract and set identifier and value tags (repeat for others) GetSetNodeValue(oXMLDocument, "mensaje/identificador/iden01", siden01, Nothing) ' ... ' Return the modified XML document Return oXMLDocument End If End If
如您所见,我没有添加 xmlns="" ,以便由肥皂响应添加。我怎样才能防止这种情况发生?

谢谢!

我尝试返回 XNode 对象而不是 XmlDocument 并在标签内搜索 xmlns="" 并将其删除。没有任何结果。

xml vb.net web-services soap namespaces
1个回答
0
投票

ConsultarResponse

 元素绑定到命名空间并且不使用命名空间前缀。任何没有命名空间前缀的后代元素都将位于 
http://sebagos.bi.com.gt/Consultar 命名空间中。因此,它需要 xmlns=""
 来指示没有与 
mensaje
 元素(及其后代)关联的命名空间,并且它们不绑定到 
http://sebipagos.bi.com.gt/Consultar 命名空间。

如果您不想在

xmlns=""

 元素上看到 
mensaje
,那么您需要让 
ConsultartResponse
 使用命名空间前缀,或者不绑定到命名空间。

© www.soinside.com 2019 - 2024. All rights reserved.