gpt4 book ai didi

xml - 如何使用 xml 和 VB.net 请求和响应?

转载 作者:数据小太阳 更新时间:2023-10-29 01:59:04 29 4
gpt4 key购买 nike

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

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

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

最佳答案

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

关于xml - 如何使用 xml 和 VB.net 请求和响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13866712/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com