In The Hand
ObexWebRequest Class
NamespacesInTheHand.NetObexWebRequest
.NET Components for Mobility
Provides an OBEX implementation of the WebRequest class.
Declaration Syntax
C#Visual Basic
public class ObexWebRequest : WebRequest
Public Class ObexWebRequest _
	Inherits WebRequest
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
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.)
AuthenticationLevel
Gets or sets values indicating the level of authentication and impersonation used for this request.
(Inherited from WebRequest.)
BeginGetRequestStream(AsyncCallback, Object) HostProtectionAttribute.
When overridden in a descendant class, provides an asynchronous version of the GetRequestStream()()() method.
(Inherited from WebRequest.)
BeginGetResponse(AsyncCallback, Object)
Begins a request for a OBEX server response.
(Overrides WebRequest.BeginGetResponse(AsyncCallback, Object).)
CachePolicy
Gets or sets the cache policy for this request.
(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.)
CreateObjRef(Type)
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
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)
Begins a request for a OBEX server response.
(Overrides WebRequest.EndGetResponse(IAsyncResult).)
Equals(Object)
Determines whether the specified Object is equal to the current 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.
(Inherited from Object.)
GetLifetimeService()()()
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
GetObjectData(SerializationInfo, StreamingContext)
Populates a SerializationInfo with the data needed to serialize the target object.
(Inherited from WebRequest.)
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
Specifies a collection of the name/value pairs that make up the OBEX headers.
(Overrides WebRequest.Headers.)
ImpersonationLevel
Gets or sets the impersonation level for the current request.
(Inherited from WebRequest.)
InitializeLifetimeService()()()
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
MemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
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()()()
Returns a String that represents the current Object.
(Inherited from Object.)
UseDefaultCredentials
When overridden in a descendant class, gets or sets a Boolean value that controls whether DefaultCredentials are sent with requests.
(Inherited from WebRequest.)
Remarks

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.

The PUT operation is supported, and there is new support for GET, (see the documentation at the Method property). Changing folders is not supported, nor is getting a folder listing.

In the previous version there were some issue with handling file names that include non-English characters, and connections to some device types failed. Also if the connection to the peer was lost then the request could hang reading forever. See the release note and bugs database for more information.

Examples
Use code like the following to send a file.
CopyC#
' 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)
Or, to send locally generated content use something like the following.
CopyC#
' 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)
See also the ObexPushApplication and ObexPushVB sample programs.
Inheritance Hierarchy

Assembly: InTheHand.Net.Personal (Module: InTheHand.Net.Personal) Version: 3.0.0.0