on 2007 Jul 17 4:54 PM
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
Request clarification before answering.
Hi Beena,
check the Methods in com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.api at the following link
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
73 | |
30 | |
8 | |
8 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.