Partager via


IWSDOutboundAttachment::Write (Compact 2013)

3/26/2014

This method sends attachment data to the remote host using a MIME container.

Syntax

HRESULT Write(
  const BYTE* pBuffer,
  DWORD dwBytesToWrite,
  LPDWORD pdwNumberofBytesWritten
);

Parameters

  • pBuffer
    [in] Pointer to a buffer containing the output data. The application program is responsible for allocating and freeing this data buffer.
  • dwBytesToWrite
    [in] Number of bytes to send to the remote host from pBuffer.
  • pdwNumberofBytesWritten
    [out] Pointer to a DWORD containing the number of bytes of data actually sent to the remote host.

Return Value

The following table shows the possible error code return values.

Error code

Description

S_OK

This method completed successfully.

E_POINTER

pdwNumberofBytesWritten is NULL.

E_INVALIDARG

pBuffer is NULL.

HRESULT_FROM_WIN32 (ERROR_INVALID_OPERATION)

The outbound attachment interface has not been initialized. Call WSDCreateOutboundAttachment to initialize the interface.

STG_S_BLOCK

Internal buffers were not available. The data was not accepted and queued for transmission.

Remarks

The Write method allows an application program to send arbitrary data to a remote host as a MIME-encapsulated message attachment. The first call to Write opens the outbound attachment stream and initiates transmission of the HTTP headers, envelope data, and the MIME-encoded application data. Subsequent calls to Write will send additional blocks of MIME-encoded application data until the application makes a call to IWSDOutboundAttachment::Close, which closes the attachment stream and finishes the transmission of the message envelope data and headers.

The Write operation may block under several conditions. On the initial operation Write may block until the transmission of the HTTP headers and XML content has been completed. On subsequent operations Write may block until the completion of the previous Write operation. Write may block for up to 30 seconds (per HTTP transmission timeouts) in the event the remote host does not reply.

If an error occurs in establishing a connection or transmitting headers, Write will return the error code immediately. If a data transfer error occurs, the error may be delayed to a future call of Write or Close.

The Write method may return successfully after a failed Write attempt that returned STG_S_BLOCK. A subsequent success indicates that the internal buffers were freed for use after the initial failed attempt. When STG_S_BLOCK is received by an application, the application can either resend the same data using the Write method or terminate the data transfer using the IWSDOutboundAttachment::Abort method.

Requirements

Header

wsdapi.h

Library

wsdapi.lib

See Also

Reference

IWSDOutboundAttachment
Web Services on Devices Interfaces