cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service client to read attachments

Former Member
0 Kudos
191

Hi,

I want to write a client for web service which returns attachment.

I want to read this attachment in client and save it as a file.

Please help...

Thanks in advance.

Beena

Accepted Solutions (1)

Accepted Solutions (1)

former_member239282
Active Participant
0 Kudos

Hi Beena,

check the Methods in com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api at the following link

https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/services/sal/url/api/class-use/W...

The following GetImage method implements the WebMethod that returns the requested JPEG files:

Copy Code

[WebMethod]

public string[] GetImage(string[] imageNameCollection)

{

// Get the SoapContext for the response message

SoapContext myContext = HttpSoapContext.ResponseContext;

// Create an array that returns URIs for the related DIME attachments.

string[] retUri= new string[imageNameCollection.Length];

int i = 0; // Iterrator

// Create a DimeAttachment object for each file specified

// by the values of the imageID array.

Foreach (string imageName in imageNameCollection)

{

// String that represents the file name and path for the attachment.

string filePath = "C:
images
" + imageName + ".jpg";

// Create a new DIME attachment using the the file name and

// specifying the encoding of the attachment using the MIME media

// type of image\jpeg.

DimeAttachment dimeImage = new DimeAttachment(

"image/jpeg", TypeFormatEnum.MediaType,

filePath);

// Generate a GUID-based URI reference for the attachment object

// and assign in to the ID property of the DIME record.

dimeImage.Id = "uri:" + Guid.NewGuid().ToString();

// Add the new DimeAttachment object to the SoapContext object.

myContext.Attachments.Add(dimeImage);

// Add the generated URI to array that is returned.

retUri<i> = dimeImage.Id;

i++;

}

// Return the array of URIs that match the ID vaules of

// the attachments.

return retUri;

}

In this WebMethod, the SOAP request message from the client contains a collection of image names. For each name in the collection, the Web service retrieves an associated JPEG file from the C:\images folder and adds the image to the DimeAttachmentCollection for the ResponseContext

      • if it helpful reward point are appreciated

Former Member
0 Kudos

Hi Pierluigi,

Thanks for the help.

But I dont want to add attachments in webmethod.

I already have a web service which is deployed on AXIS server that returns an attachment.

I want to access this attachment in my web service client.

I have already created a web service client using NWDS.

Now I dont know how to read attachment.

I have also generated a web service client for same WSDL using wsdl2java.

Here I can read attachment (I found method to get messagecontext).

But I dont see any method which returns messagecontext in the client generated using NWDS.

Please help.

Thanks,

Beena.

Answers (0)