5

我被要求向服务器发送请求以在线注册积分收集系统的交易。我对这个请求-响应程序了解不多。

他们告诉我请求应该是这样的:

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。感谢您的时间。

4

1 回答 1

0

在 Visual Studio 中添加对 WSDL url 的引用。

于 2013-05-07T12:23:22.383 回答