473,569 Members | 2,747 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 = ResponseSoapCon text.Current;
DimeAttachment dimeAttach = new DimeAttachment( "applicatio n/msword",
TypeFormat.Medi aType,
@"D:\Images\Tes t.doc");
respContext.Att achments.Add(di meAttach);
}

On Client:
----------
private void btnGetDoc_Click (object sender, System.EventArg s e)
{
MyDimeService svc = new MyDimeService() ;
svc.GetDoc();
if (svc.ResponseSo apContext.Attac hments.Count == 1)
{
MessageBox.Show ("Got it!\n");
// Get the stream and do something with it
Stream s = svc.ResponseSoa pContext.Attach ments[0].Stream;
byte [] binaryData = new byte[s.Length];
long bytesRead = s.Read(binaryDa ta, 0, binaryData.Leng th);
s.Close();
string base64String;
try
{
base64String = System.Convert. ToBase64String( binaryData, 0,

binaryData.Leng th);
}
catch (System.Argumen tNullException)
{
System.Console. WriteLine("Bina ry 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 2433
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.goo gle.com...
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 = ResponseSoapCon text.Current;
DimeAttachment dimeAttach = new DimeAttachment( "applicatio n/msword",
TypeFormat.Medi aType,
@"D:\Images\Tes t.doc");
respContext.Att achments.Add(di meAttach);
}

On Client:
----------
private void btnGetDoc_Click (object sender, System.EventArg s e)
{
MyDimeService svc = new MyDimeService() ;
svc.GetDoc();
if (svc.ResponseSo apContext.Attac hments.Count == 1)
{
MessageBox.Show ("Got it!\n");
// Get the stream and do something with it
Stream s = svc.ResponseSoa pContext.Attach ments[0].Stream;
byte [] binaryData = new byte[s.Length];
long bytesRead = s.Read(binaryDa ta, 0, binaryData.Leng th);
s.Close();
string base64String;
try
{
base64String = System.Convert. ToBase64String( binaryData, 0,

binaryData.Leng th);
}
catch (System.Argumen tNullException)
{
System.Console. WriteLine("Bina ry 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
1950
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 services on a windows box, which returns a DIME attachment. DIME doesn't appear to use the same boundaryies as a MIME message. Thanks for any...
0
1141
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 from one method to the next, the only difference being that one accepts the transfer of an attachment using DIME and the other does not. When the...
1
1973
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 DimeAttachment("application/DIME", TypeFormatEnum.MediaType, @"c:\temp\" + filename); sc.Attachments.Add(dimeFile);
4
6374
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 attachment: MyDimeService svc = new MyDimeService(); svc.CreateDimedImage(); if (svc.ResponseSoapContext.Attachments.Count == 1) {
2
1543
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 sent back to the client. So there seems to be nothing wrong at all, except: This is UNBELIEVEABLY slow! My last tests were with a 4MB file. The...
0
1150
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 attachment So the first problem is getting it from the back end tier to the middle tier The middle tier calls the back end tier to get the...
4
5895
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
4373
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 format). I need to write a WS client to consume this Soap Response and save the attachment in my system. Problems:
5
3237
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 implementation had problems consuming too large files that way. They encountered a memory leak in the parser that made the whole mainframe environment to...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2107
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 we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.