| C# | Visual Basic |
public class ObexWebRequest : WebRequest
Public Class ObexWebRequest _ Inherits WebRequest
| All Members | Constructors | Methods | Properties | ||
| Icon | Member | Description |
|---|---|---|
| ObexWebRequest(Uri) |
Create a new Obex request with the specified Uri.
| |
| ObexWebRequest(Uri, Stream) |
[Advanced usage]
Create a new Obex request with the specified Uri
and the open Stream connection to an OBEX server.
| |
| Abort()()() | Aborts the Request (Inherited from WebRequest.) | |
| BeginGetRequestStream(AsyncCallback, Object) | When overridden in a descendant class, provides an asynchronous version of the GetRequestStream()()() method. (Inherited from WebRequest.) | |
| BeginGetResponse(AsyncCallback, Object) | When overridden in a descendant class, begins an asynchronous request for an Internet resource. (Inherited from WebRequest.) | |
| ConnectionGroupName | When overridden in a descendant class, gets or sets the name of the connection group for the request. (Inherited from WebRequest.) | |
| ContentLength |
Gets or sets the Length OBEX header.
(Overrides WebRequest.ContentLength.) | |
| ContentType |
Gets or sets the value of the Type OBEX header.
(Overrides WebRequest.ContentType.) | |
| Credentials | When overridden in a descendant class, gets or sets the network credentials used for authenticating the request with the Internet resource. (Inherited from WebRequest.) | |
| EndGetRequestStream(IAsyncResult) | When overridden in a descendant class, returns a Stream for writing data to the Internet resource. (Inherited from WebRequest.) | |
| EndGetResponse(IAsyncResult) | When overridden in a descendant class, returns a WebResponse. (Inherited from WebRequest.) | |
| Equals(Object) | (Inherited from Object.) | |
| Finalize()()() | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
| GetHashCode()()() | Serves as a hash function for a particular type. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) | |
| GetRequestStream()()() |
Gets a Stream object to use to write request data.
(Overrides WebRequest.GetRequestStream()()().) | |
| GetResponse()()() |
Returns the OBEX server response.
(Overrides WebRequest.GetResponse()()().) | |
| GetType()()() | Gets the Type of the current instance. (Inherited from Object.) | |
| Headers | ||
| MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| Method |
Gets or sets the method for the request.
(Overrides WebRequest.Method.) | |
| PreAuthenticate | When overridden in a descendant class, indicates whether to pre-authenticate the request. (Inherited from WebRequest.) | |
| Proxy |
Not Supported - do not use, this will throw an exception.
(Overrides WebRequest.Proxy.) | |
| ReadFile(String) |
Reads the contents of the specified file to the request stream.
| |
| RequestUri |
Gets the original Uniform Resource Identifier (URI) of the request.
(Overrides WebRequest.RequestUri.) | |
| Timeout |
Gets or sets the time-out value for the GetResponse()()() method.
(Overrides WebRequest.Timeout.) | |
| ToString()()() | (Inherited from Object.) |
If you want to transfer an file or other object using the standard service as used by Windows' Wireless Link / Bluetooth File Transfer Wizard, Palm's Beam, Nokia's Send via Infrared, then use the OBEX protocol.
Only the PUT operation is supported, GET is not, nor is changing folders or getting a folder listing. There are some issue with handling file names that include non-English characters, and in the previous version connections to some device types failed.
Note that unlike the framework's HttpWebResponse class etc, which signals an error by throwing a WebException, the ObexWebRequest class signals an error by returning an error status code in ObexWebResponse.StatusCode. Status code BadRequest indicates an error at connect time, in the network connection, the OBEX connection or even in the format or content of the URI. Status code InternalServerError indicates an error during the transfer. The new ObexWebRequest2 class behaves like the framework classes, throwing a WebException and it includes the original error as the InnerException property.
' The host part of the URI is the device address, e.g. IrDAAddress.ToString(), ' and the file part is the OBEX object name. Dim uri As New Uri("obex://112233445566/HelloWorld.txt") Dim req As New ObexWebRequest(uri) req.ReadFile("Hello World.txt") Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse) Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
' The host part of the URI is the device address, e.g. IrDAAddress.ToString(), ' and the file part is the OBEX object name. Dim uri As New Uri("obex://112233445566/HelloWorld2.txt") Dim req As New ObexWebRequest(uri) Using content As Stream = req.GetRequestStream() ' Using a StreamWriter to write text to the stream... Using wtr As New StreamWriter(content) wtr.WriteLine("Hello World GetRequestStream") wtr.WriteLine("Hello World GetRequestStream 2") wtr.Flush() ' Set the Length header value req.ContentLength = content.Length End Using ' In this case closing the StreamWriter also closed the Stream, but ... End Using Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse) Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)
| Object | ||||
| MarshalByRefObject | ||||
| WebRequest | ||||
| ObexWebRequest | ||||
| ObexWebRequest2 | ||||