我正在编写一个调用另一个Web服务的Web服务。
所调用的函数之一是“viewticket”,由.NET发现,如下所示。
'''<remarks/>
<System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace:="http://blablabla.com", ResponseNamespace:="http://blablabla.com")> _
Public Function viewTicket(ByVal sentinelUser As SentinelUser, ByVal [string] As String) As <System.Xml.Serialization.SoapElementAttribute("result")> SentinelResponse
Dim results() As Object = Me.Invoke("viewTicket", New Object() {sentinelUser, [string]})
Return CType(results(0), SentinelResponse)
End Function
返回的SentinelResponse是一个包含几个字段的XML文件
- <xsd:complexType name="Fields">
- <xsd:sequence>
<xsd:element maxOccurs="1" nillable="true" name="BTN" type="xsd:string" minOccurs="1" />
<xsd:element maxOccurs="1" nillable="true" name="CPUID" type="xsd:string" minOccurs="1" />
<xsd:element maxOccurs="1" nillable="true" name="DNIS" type="xsd:string" minOccurs="1" />
<xsd:element maxOccurs="1" nillable="true" name="DNSHostname" type="xsd:string" minOccurs="1" />
<xsd:element maxOccurs="1" nillable="true" name="Description" type="xsd:string" minOccurs="1" />
<xsd:element maxOccurs="1" nillable="true" name="Kweethetniet" type="xsd:string" minOccurs="1" />
.....
其背后的数据库中的描述字段似乎有时会填充非法字符(ascii 1-20)。 一旦调用该字段被提取,我就会收到错误
' '''<remarks/>
<System.Xml.Serialization.SoapElementAttribute(IsNullable:=True)> _
Public Property descriptionText() As String
Get
Return Me.descriptionTextField
End Get
Set(value As String)
Me.descriptionTextField = value
End Set
End Property
有没有办法从被调用的webservice“拦截”返回的XML流,并首先通过regex.replace运行它来过滤掉这些非法字符?
遗憾的是,我无法访问后端系统。