UtilWebPostXmlHttpRequestAsync(String, XDocument, Encoding, ActionHttpWebRequest) Method
Asynchronously posts an XML HTTP request to the specified server with a custom Encoding, and returns the response.
Namespace: DevCase.Core.Networking.CommonAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static Task<XDocument> PostXmlHttpRequestAsync(
string url,
XDocument xml,
Encoding enc,
Action<HttpWebRequest> request
)
Public Shared Function PostXmlHttpRequestAsync (
url As String,
xml As XDocument,
enc As Encoding,
request As Action(Of HttpWebRequest)
) As Task(Of XDocument)
Dim url As String
Dim xml As XDocument
Dim enc As Encoding
Dim request As Action(Of HttpWebRequest)
Dim returnValue As Task(Of XDocument)
returnValue = UtilWeb.PostXmlHttpRequestAsync(url,
xml, enc, request)
public:
static Task<XDocument^>^ PostXmlHttpRequestAsync(
String^ url,
XDocument^ xml,
Encoding^ enc,
Action<HttpWebRequest^>^ request
)
static member PostXmlHttpRequestAsync :
url : string *
xml : XDocument *
enc : Encoding *
request : Action<HttpWebRequest> -> Task<XDocument>
No code example is currently available or this language may not be supported.
- url String
-
The server url.
- xml XDocument
-
A XDocument that represents the XML content to POST to the server.
- enc Encoding
-
The text encoding.
- request ActionHttpWebRequest
-
A HttpWebRequest object that represents the request parameters and custom header values.
(It is not necessary to set the Method and ContentLength properties)
TaskXDocument
The resulting response returned by the server.
This is a code example that demonstrates how to POST a XmlHttpRequest to http://converter.telerik.com/service.asmx service.
No code example is currently available or this language may not be supported.
Dim xml As XDocument =
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConvertToCS xmlns="http://converter.telerik.com">
<vbCode>Dim str As String = "Hello World"</vbCode>
</ConvertToCS>
</soap12:Body>
</soap12:Envelope>
Dim result As XDocument =
Await PostXmlHttpRequestAsync("http://converter.telerik.com/service.asmx", xml, Encoding.UTF8,
Sub(req As HttpWebRequest)
req.Method = "POST"
req.Host = "converter.telerik.com"
req.ContentType = "application/soap+xml; charset=utf-8"
req.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"
req.Credentials = New NetworkCredential()
req.KeepAlive = False
End Sub)
Dim ns As XNamespace = result.Root.Name.Namespace
Dim el As XElement = result.Element(ns + "Envelope").Element(ns + "Body")
Console.WriteLine(el.Value)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.