Sending DimeAttachment from a SoapClient to a SoapServer over TCP/

Discussion in 'ASP .Net Web Services' started by KodeCruncher, May 15, 2006.

  1. KodeCruncher

    KodeCruncher Guest

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

    }
     
    KodeCruncher, May 15, 2006
    #1
    1. Advertising

  2. KodeCruncher

    KodeCruncher Guest

    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";






    "KodeCruncher" wrote:

    > 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 + "%");
    > }
    >
    > }
     
    KodeCruncher, May 15, 2006
    #2
    1. Advertising

  3. KodeCruncher

    John Fullmer Guest

    John Fullmer, May 16, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael
    Replies:
    0
    Views:
    201
    Michael
    May 13, 2004
  2. Asha
    Replies:
    0
    Views:
    343
  3. Christopher Crooker

    WSE 2.0 SP1 SoapClient/Service and NAT

    Christopher Crooker, Aug 1, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    157
    Christopher Crooker
    Aug 3, 2004
  4. Jack Wright
    Replies:
    1
    Views:
    311
    Jack Wright
    Aug 25, 2004
  5. RobertHillEDS
    Replies:
    2
    Views:
    252
    Steven Cheng[MSFT]
    Sep 22, 2005
Loading...

Share This Page