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 + "%");
}
}
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 + "%");
}
}