Imports System
Imports System.Linq
Imports System.Net
Imports System.Windows.Forms
Imports System.Xml.Linq
Public Class Form1
'
URL
Private address As String = "http://192.168.1.123/cgi-bin/service.cgi?param1=abc¶m2=10000"
'
XML namespace
Private
soap As XNamespace = "http://schemas.xmlsoap.org/
soap/envelope/"
Private epos As XNamespace = "http://www.xxx.com/schemas/2011/03/xxx"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' Create document
Dim req As XElement = _
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/
soap/envelope/">
<s:Body>
<xxxt-yyy xmlns="http://www.xxx.com/schemas/2011/03/xxx">
<text lang="en">Testtext</text>
</xxx-yyy>
</s:Body>
</s:Envelope>
' Send document
Dim client As WebClient = New WebClient()
client.Headers.Set("Content-Type", "text/
xml; charset=utf-8")
AddHandler client.UploadStringCompleted, AddressOf UploadStringCompletedEventHandler
client.UploadStringAsync(New
Uri(address, UriKind.Absolute), req.ToString())
End Sub
' Receive response document
Private Sub UploadStringCompletedEventHandler(sender As Object, e As UploadStringCompletedEventArgs)
If (e.Error IsNot Nothing) Then
MessageBox.Show(e.Error.Message)
Else
'Parse response document
Dim res As XElement = XElement.Parse(e.Result)
Dim c = From el In res.Descendants(epos + "response") Select el.Attribute("success")
MessageBox.Show(c.First().Value)
End If
End Sub
End Class