我被要求向服务器发送请求以在线注册点收集系统的交易。我不太了解这个请求响应程序。
他们告诉我,请求应该是这样的:
request(
p1 - loginInfo:UN|PASS|MP1
p2 - XMLTransactionInfo (below)
p3 - returnPointBalance:1
)
<transaction>
<partnernum>000001</partnernum>
<trxndate>2012-10->12T07:18:27</trxndate>
<cardnum>1234567891234567</cardnum>
<trxnamount>5.4</trxnamount>
<trxnpoints>729</trxnpoints>
<posnum>000-001</posnum>
<contactidnum></contactidnum>
<contactphone>357</contactphone>
<trxnseqnum>12345612345612</trxnseqnum>
</transaction>
响应应该是这样的:
response(
<?xml version="1.0" encoding="UTF-8"?>
<transactionresponse xmlns="C:\path\Sth.ear\Sth.war/xmlschema/TransactionResponse.rng">
<sequencenum>123123121312</sequencenum>
<errorcode>0</errorcode>
<errormessage></errormessage>
<trxnnum>6399575</trxnnum>
<balancebefore>1942</balancebefore>
<balanceafter>1213</balanceafter>
<mpcontrib>729</mpcontrib>
<partnercontrib>0</partnercontrib>
</transactionresponse>
)
他们还告诉我:“你可以使用这个URL获取WSDL:url1 ......”和“WS端点是:url2 ......”
到目前为止,我已成功完成以下任务:
Dim request As WebRequest = Nothing
'Create a request for the URL.
request =WebRequest.Create("URL1")
'set the credentials.
Dim credentials As NetworkCredential
loginUser = "username"
loginPass = "pass"
credentials = New NetworkCredential(loginUser, loginPass, "MP1")
request.Credentials = credentials
'create the transaction xml
request.ContentType = "text/xml"
Dim transaction As XmlElement
transaction = xml2.CreateElement("transaction")
xml2.AppendChild(transaction)
Dim partnernum As XmlElement
partnernum = xml2.CreateElement("partnernum")
partnernum.InnerText = "00001"
transaction.AppendChild(partnernum)
'and so on until i create the exact same xml as above...
然后我将XML文件打印到控制台进行目视检查,然后请求回复
'print to console
xml2.Save(Console.Out)
Dim response As WebResponse = request.GetResponse()
Console.WriteLine(response.ToString())
'write the response to a textbox
responseText.Text = response.Headers.ToString()
文本框中的响应结果是
Content-Language: el-GR
Transfer-Encoding: chunked
Content-Type: text/xml
Date: Thu, 13 Dec 2012 18:52:33
GMT Server: WebSphere Application Server/6.0
首先,我应该使用他们给我的2个网址中的哪一个?
其次,如何创建他们告诉我的请求以获得我想要的回复?
是否有任何分步指导?
我正在使用VB.net,WinForms。 谢谢你的时间。
答案 0 :(得分:1)
您正尝试使用VB.NET访问Web服务。
在Visual Studio中,您应该能够添加Web引用(或服务引用,具体取决于您使用的项目类型和VS版本)。
看一下本教程:http://www.a2zdotnet.com/View.aspx?Id=191#.U9B6ZPmSyuo
有关.NET Web服务的更多信息:http://msdn.microsoft.com/en-us/library/t745kdsh(v=vs.90).aspx
答案 1 :(得分:0)
在Visual Studio中添加对WSDL URL的引用。