473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send a DIME attachment with SOAP

Hi!

I am trying SOAP with DIME attachments in web services. The web
service sends the file as attachment say "test.doc", and the client
has to read that and populate it in a textbox control. I had asked
this question earlier, and got the reply that the data is tranferred
in binary format on the wire. I read the stream, and convert it to
string, but I get some junk characters in my textbox. I am writing my
code below, so that you can see what I am doing wrong, and correct me.
This is what I do:

On Server:
----------
[WebMethod]
public void GetDoc()
{
SoapContext respContext = ResponseSoapContext.Current;
DimeAttachment dimeAttach = new DimeAttachment("application/msword",
TypeFormat.MediaType,
@"D:\Images\Test.doc");
respContext.Attachments.Add(dimeAttach);
}

On Client:
----------
private void btnGetDoc_Click(object sender, System.EventArgs e)
{
MyDimeService svc = new MyDimeService();
svc.GetDoc();
if (svc.ResponseSoapContext.Attachments.Count == 1)
{
MessageBox.Show("Got it!\n");
// Get the stream and do something with it
Stream s = svc.ResponseSoapContext.Attachments[0].Stream;
byte [] binaryData = new byte[s.Length];
long bytesRead = s.Read(binaryData, 0, binaryData.Length);
s.Close();
string base64String;
try
{
base64String = System.Convert.ToBase64String(binaryData, 0,

binaryData.Length);
}
catch (System.ArgumentNullException)
{
System.Console.WriteLine("Binary data array is null.");
return;
}
txtGetDoc.Text = base64String;
} //end of if
} //end of private..

Waiting for an answer...

Thanks
Ipsita
Nov 18 '05 #1
1 2424
what are you expecting to appear in the textbox?

from your code I'd expect the textbox to contain the base64 string which is
the encoding of the binary data, and from your description it sounds like
you are getting that.

a textbox only supports displaying plain text, if test.doc cannot be viewed
correctly with notepad.exe, a textbox cannot either.

-- bruce (sqlwork.com)

"Ipsita" <ip************@gmail.com> wrote in message
news:ef**************************@posting.google.c om...
Hi!

I am trying SOAP with DIME attachments in web services. The web
service sends the file as attachment say "test.doc", and the client
has to read that and populate it in a textbox control. I had asked
this question earlier, and got the reply that the data is tranferred
in binary format on the wire. I read the stream, and convert it to
string, but I get some junk characters in my textbox. I am writing my
code below, so that you can see what I am doing wrong, and correct me.
This is what I do:

On Server:
----------
[WebMethod]
public void GetDoc()
{
SoapContext respContext = ResponseSoapContext.Current;
DimeAttachment dimeAttach = new DimeAttachment("application/msword",
TypeFormat.MediaType,
@"D:\Images\Test.doc");
respContext.Attachments.Add(dimeAttach);
}

On Client:
----------
private void btnGetDoc_Click(object sender, System.EventArgs e)
{
MyDimeService svc = new MyDimeService();
svc.GetDoc();
if (svc.ResponseSoapContext.Attachments.Count == 1)
{
MessageBox.Show("Got it!\n");
// Get the stream and do something with it
Stream s = svc.ResponseSoapContext.Attachments[0].Stream;
byte [] binaryData = new byte[s.Length];
long bytesRead = s.Read(binaryData, 0, binaryData.Length);
s.Close();
string base64String;
try
{
base64String = System.Convert.ToBase64String(binaryData, 0,

binaryData.Length);
}
catch (System.ArgumentNullException)
{
System.Console.WriteLine("Binary data array is null.");
return;
}
txtGetDoc.Text = base64String;
} //end of if
} //end of private..

Waiting for an answer...

Thanks
Ipsita

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1942
by: Chris C | last post by:
I've been looking all around for any libraries or code for parsing dime attachments from Microsoft .NET Web Services. Any ideas? I am writing my client code on a linux box and calling SOAP web...
0
1130
by: Vaylor Trucks | last post by:
I have a web service written in ASP.NET using the .NET frame v1.1.4322 and Web Service Enhancements 1.0 SP1. This web service has 2 nearly identical methods. That is, the SOAP XML is the same...
1
1968
by: Levi Wilson | last post by:
I have a web service that adds a DIME attachment: public void GetFile(string filename) { SoapContext sc = HttpSoapContext.ResponseContext; DimeAttachment dimeFile = new...
4
6367
by: Scott, Killer of all Ninjas | last post by:
It seems incredulous to me that it is so difficult to write the contents of a memory stream to a file. I'm certain that I'm missing something simple. I am retrieving a memory stream from a DIME...
2
1539
by: Sven Thorsen | last post by:
I have a Web Service with a method that handles file uploads. The file is sent as a DIME attachment to the SOAP request. The post is successful, the file is received and the correct response is...
0
1148
by: Stu | last post by:
Hi, I have a 3 tier system using web services I want to attach on the 3rd tier - data access to the middle tier - business rules and call the business rule tier from the front end to get the...
4
5889
by: Sean Feldman | last post by:
Hello, I've installed WSE2 and succedded to download from WebService DataTable object, but can't do the oposite. Anyone can help please? Thanks a lot!
1
4368
by: pratishsoma | last post by:
Hi, I'm developing WebServices client in Visual Studio 2005. The Web Service is developed in java, Axis. The Web Service has a function to return Soap Response and an Attachment (DIME or MIME...
5
3228
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= | last post by:
I have never sent attachment with webservices. Yesterday I got the challenge to redesign my solution that sends large XML structures to a Java webservice. The reason was that the Java SOAP...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.