Home > Software engineering >  Vb to call the webservice prompt "" lack of the root element" "
Vb to call the webservice prompt "" lack of the root element" "

Time:09-17

The Function HttpPost (Url As a String, PostMsg As String) As String
'to write their own send Post function
'function, the return value is the return of information (HTML)
'the first parameter is the Url to send
'the second parameter is to send the message (keys, don't need to code)
Dim XmlHttp As Object
The Set XmlHttp=CreateObject (" Msxml2. XmlHttp ")
If Not IsObject (XmlHttp) Then
The Set XmlHttp=CreateObject (" Microsoft. XmlHttp ")
If Not IsObject (XmlHttp) Then the Exit Function
End the If
XmlHttp. Open the "POST", Url, False, Null, Null
XmlHttp. SetRequestHeader content-type ", "" application/x - WWW - form - urlencoded"
XmlHttp. Send (PostMsg)
The Do While XmlHttp. ReadyState & lt;> 4
DoEvents
Loop
'IF the following line (IF) and the back of the End of annotation, which is set to only when the return code is 200 to return to the page content
'If XmlHttp. Status=200 Then
HttpPost=XmlHttp. The responseText
'End If
End the Function
'put this function in the form/module directly, don't need to refer to anything

Private Sub Form_Load ()
Dim PostMsg As String
On the Error Resume Next
'PostMsg="& lt; ? XmlPOST/WebServices/WeatherWebService. Asmx HTTP/1.1 "
'PostMsg=PostMsg & amp; "Host:www.webxml.com.cn"
'PostMsg=PostMsg & amp; "The content-type: text/XML; Charset=utf-8 "
'PostMsg=PostMsg & amp; "The Content - length: 2000"
'PostMsg=PostMsg & amp; "SOAPAction:" http://WebXml.com.cn/getWeatherbyCityName "" ""
'PostMsg=PostMsg & amp; "& lt; ? XML version="1.0" "encoding=" utf-8 ""? & gt;"
'PostMsg=PostMsg & amp; "& lt; The 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/" "& gt;"
'PostMsg=PostMsg & amp; "& lt; Soap: Body>"
'PostMsg=PostMsg & amp; "& lt; GetWeatherbyCityName XMLNS="" http://WebXml.com.cn" "& gt;"
'PostMsg=PostMsg & amp; "& lt; TheCityName> Shijiazhuang & lt;/theCityName>"
'PostMsg=PostMsg & amp; "& lt;/getWeatherbyCityName>"
'PostMsg=PostMsg & amp; "& lt;/soap: Body>"
'PostMsg=PostMsg & amp; "& lt;/the soap: Envelope/? & gt;"
PostMsg="& lt; ? XmlPOST/WebServices/WeatherWebService asmx getWeatherbyCityName HTTP/1.1 "
PostMsg=PostMsg & amp; "Host: www.webxml.com.cn
"PostMsg=PostMsg & amp; "The content-type: application/x - WWW - form - urlencoded"
PostMsg=PostMsg & amp; "The Content - length: 1000"
PostMsg=PostMsg & amp; "TheCityName=shijiazhuang? & gt;"
RichTextBox1. Text=HttpPost (" http://www.webxml.com.cn/WebServices/WeatherWebService.asmx? Op=getWeatherbyCityName ", PostMsg)
Text1. Text=PostMsg
End Sub

CodePudding user response:

POST/WebServices/WeatherWebService. Asmx HTTP/1.1
Host: www.webxml.com.cn
The content-type: text/XML. Charset=utf-8
The Content - Length: Length
SOAPAction: "http://WebXml.com.cn/getWeatherbyCityName"

<? The XML version="1.0" encoding="utf-8"?>

String



HTTP/1.1 200 OK
The content-type: text/XML. Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>


String
String




This is the weather sites for instance, demo, I is according to the steps,

CodePudding user response:

Prompt the,
<? The XML version="1.0" encoding="utf-8"?> Soap: Receiver

CodePudding user response:

reference 1st floor liyanzhao2016 response:
POST/WebServices/WeatherWebService asmx HTTP/1.1
Host: www.webxml.com.cn
The content-type: text/XML. Charset=utf-8
The Content - Length: Length
SOAPAction: "http://WebXml.com.cn/getWeatherbyCityName"
.............
This is the weather sites for instance, demo, I is according to the steps,


Its ", demonstrated "web URL posted, let everybody to see directly,
Copy of your "out of context" a heap of, who knows whether you have this in right,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related