Sending DimeAttachment from a SoapClient to a SoapServer over TCP/

K

KodeCruncher

Following is the code snippet.
StockQuoteClient inherits from SoapClient.
SoapClient calls a soapmethod through tcp/ip.
I need to add an attachment to my request.

when I try to get the current soapcontext using the following code it is
null.

SoapContext reqContext = RequestSoapContext.Current;

Any help is appreciated thanks.

private void btnGo_Click(object sender, System.EventArgs e)
{
//
String[] symbols = { "FABRIKAM", "CONTOSO" };
StockQuoteRequest request = new StockQuoteRequest();
request.Symbols = symbols;

Uri address = new
Uri("soap://stockservice.contoso.com/wse/samples/2003/06/TcpSyncStockService");
Uri via = new Uri("soap.tcp://" + System.Net.Dns.GetHostName() +
"/StockService");

StockQuoteClient proxy = new StockQuoteClient( new
EndpointReference(address, via));

Console.WriteLine("Calling {0}", proxy.Destination.Address.Value);


SoapContext reqContext = RequestSoapContext.Current;
DimeAttachment dimeAttach = new DimeAttachment(
"image/gif", TypeFormat.MediaType,
@"E:\Documents and Settings\kkode\Desktop\Aruna\logo_H.gif");

reqContext.Attachments.Add(dimeAttach);

StockQuotes quotes = proxy.GetStockQuotes( request );



foreach( StockQuote quote in quotes.Quotes )
{
Response.Write("");
Response.Write( "Symbol: " + quote.Symbol );
Response.Write( "\tName:\t\t\t" + quote.Name );
Response.Write( "\tLast Price:\t\t" + quote.Last );
Response.Write( "\tPrevious Change:\t" + quote.PreviousChange + "%");
}

}
 
K

KodeCruncher

I found the solution after digging around.
we can add the attachment to the soap envelope instead.
This soapenvelope can be sent to the server.

SoapEnvelope e = new SoapEnvelope();
e.SetBodyObject(message);
DimeAttachment dimeAttach = new DimeAttachment(
"image/gif", TypeFormat.MediaType,
@"E:\Documents and Settings\kkode\Desktop\Aruna\logo_H.gif");
dimeAttach.Id="Logo";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top