微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vb.net尝试使用GET方法发出肥皂请求

如何解决vb.net尝试使用GET方法发出肥皂请求

我必须使用GET方法发出请求以获取登录令牌。

我收到此信息: 完整文档:https://doc.dpd.be/node/34

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://dpd.com/common/service/types/LoginService/2.0">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:getAuth>
         <delisId>KD*****</delisId>
         <password>*******</password>
         <messageLanguage>en_EN</messageLanguage>
      </ns:getAuth>
   </soapenv:Body>
</soapenv:Envelope>

样品响应

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getAuthResponse xmlns="http://dpd.com/common/service/types/LoginService/2.1">
         <return>
            <delisId>SWSTEST</delisId>
            <customerUid>SWSTEST</customerUid>
            <authToken>GFadfGob14GWWgQcIldI6zYtuR7cyEHe2z6eWzb7BpFmcFvrzclRljlcV1OF</authToken>
            <depot>0530</depot>
            <authTokenExpires>2020-05-08T13:02:56.06</authTokenExpires>
         </return>
      </getAuthResponse>
   </soap:Body>
</soap:Envelope>

这是我到目前为止的代码,但是如何发送信封响应呢?

 Dim Request As WebRequest
    Dim Response As WebResponse
    Dim DataStream As Stream
    Dim Reader As StreamReader
    Dim SoapByte() As Byte
    Dim SoapStr As String
    Dim pSuccess As Boolean = True

    SoapStr = "<?xml version=""1.0"" encoding=""utf-8""?>"
    SoapStr = SoapStr & "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"">"

    SoapStr = SoapStr & "<soapenv:Header/>"
    SoapStr = SoapStr & "<soapenv:Body>"
    SoapStr = SoapStr & "<ns:getAuth> <delisId>KD3379602W</delisId> <password>207Yc*-K</password> <messageLanguage>de_DE</messageLanguage> </ns:getAuth>"
    SoapStr = SoapStr & "</soapenv:Body>"
    SoapStr = SoapStr & "</soapenv:Envelope>"



    Try
        SoapByte = System.Text.Encoding.UTF8.GetBytes(SoapStr)

        Request = WebRequest.Create("https://wsshipper.dpd.be/soap/WSDL/LoginServiceV21.wsdl")
        Request.Headers.Add("SOAPAction","http://dpd.com/common/service/types/LoginService/2.1")

        Request.ContentType = "text/xml; charset=utf-8"
        Request.ContentLength = SoapByte.Length
        Request.Method = "get"

????

捕获为WebException MsgBox(例如ToString()) 结束尝试

End Sub

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。