如何将SOAP REQUEST xml(asmx)响应选中的元素放入文本框或数据集中。这是我的简单剧本:
Protected Sub SOAPRequest(ByVal tarikh As String, ByVal jabatan As String, ByVal HRMS_asmx As String, ByVal tempuri As String)
Dim xmlQuery As String = "<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Header>
<wsse:Security soap:mustUnderstand='true' xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
<wsse:UsernameToken wsu:Id='UsernameToken-3DAJDJSKJDHFJASDKJFKJ234JL2K3H2K3J42'>
<wsse:Username>660618055198</wsse:Username>
<wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>fouziah@123</wsse:Password>
<wsse:Nonce EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'>3WSOKcKKm0jdi3943ts1AQ==</wsse:Nonce>
<wsu:Created>2015-01-12T16:46:58.386Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<GetDataXMLbyDate xmlns='http://tempuri.org/'>
<tarikh>" + tarikh + "</tarikh>
<datatypes>
<NamaAgensi>" + jabatan + "</NamaAgensi>
</datatypes>
</GetDataXMLbyDate>
</soap:Body>
</soap:Envelope>"
Dim doc As New XmlDocument()
doc.LoadXml(xmlQuery)
Dim req As HttpWebRequest = CType(WebRequest.Create(HRMS_asmx), HttpWebRequest)
req.Headers.Add("SOAPAction", tempuri)
req.Headers.Add("GetDataXMLbyDateResponse", "http://temuri.org")
req.ContentType = "text/xml;charset=""utf-8"""
req.Accept = "text/xml"
req.Method = "POST"
Dim stm As Stream = req.GetRequestStream()
doc.Save(stm)
stm.Close()
Dim resp As WebResponse = req.GetResponse()
stm = resp.GetResponseStream()
Dim r As StreamReader = New StreamReader(stm)
Response.Write(r.ReadToEnd())
End Sub
enter image description here enter image description here
,第二个问题是,使用网络参考
答案 0 :(得分:0)
根据您的屏幕截图,您发布的代码与您的错误没有任何关系。
您尝试在服务引用上调用(GetDataXMLByDate
)的方法有两个参数,但您没有提供任何参数。
我不可能给你确切的代码,因为我缺少上下文,但你需要一个字符串,你需要一个NamaAgensi
的数组。因此,与您在该pageLoad方法中所做的相比,请查看此内容。
Dim arr as NamaAgensi() = New NamaAgensi(0) { someInstanceOfNamaAgensi}
service.GetDataXMLByDate(tarikh, arr)