Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7173459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:49:42+00:00 2026-05-28T15:49:42+00:00

I am having issue setting a cookie to a web-service call in .NET. Before

  • 0

I am having issue setting a cookie to a web-service call in .NET. Before using any of the calls of the wsdl provided, i must provide a cookie that is obtained upon logging in to the clients website. I have a method to login and retrieve the cookie, where I then pass it to my makeSearch method (shown below). As you can see, i’m setting the cookie in the cookieContainer for the wsdl Object; however, when i check the request made by my AdvancedSearch method, i’m noticing in fiddler that no cookie is being sent. The client provided the solution in Java, but am having issue transferring that to .NET.

The following is the solution in Java code: (port is the wsdl object passed in)

private static void setupClient(Object port, final String cookie) throws Exception {
    Client client = ClientProxy.getClient(port); 
    HTTPConduit http = (HTTPConduit) client.getConduit();
    HTTPClientPolicy policy = http.getClient();
    if (policy == null) {
        policy = new HTTPClientPolicy();
        http.setClient(policy);
    }
    policy.setCookie(cookie);
    policy.setAutoRedirect(true);
}

My code is the following:

public AdvancedSearchResult makeSearch(String cookie) {
    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
    AdvancedSearchResult searchResults = new AdvancedSearchResult();
    Cookie cook= new Cookie("NAME", HttpUtility.UrlEncode(cookie));
    searches.CookieContainer = new CookieContainer();
    searches.CookieContainer.Add(newUri(www.test.com),cook);
    searchResults = searches.AdvancedSearch("search params");
    return searchResults;
}

Can anyone list any ideas or solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:49:43+00:00Added an answer on May 28, 2026 at 3:49 pm

    I just had this same problem and here is how I solved it

    var tmWebServices             = new TM_WebServices();
    tmWebServices.CookieContainer = new System.Net.CookieContainer();
    tmWebServices.Url             = Test_TM.tmWebServices;
    
    var username     = "reader";  
    var passwordHash = Test_TM.passwordHash_Reader;
    var sessionID    =  tmWebServices.Login(username, passwordHash);
    
    //Note that this is optional if you set these cookies from the server side
    var cookie       =  new System.Net.Cookie("Session",sessionID.str());
    tmWebServices.CookieContainer.Add(tmWebServices.Url.uri() , cookie); 
    
    var guidanceItemID = "0c85a318-0c32-4417-9d72-7475bb96517e".guid();
    
    var guidanceItemHtml = tmWebServices.GetGuidanceItemHtml(guidanceItemID);
    
    return "{0}".format(guidanceItemHtml);
    
    
    //using O2.SecurityInnovation.TeamMentor
    //O2File:TM_WebServices.cs
    //O2File:Test_TM_Config.cs
    //O2Ref:System.Web.Services.dll
    

    The key was adding the

    tmWebServices.CookieContainer = new System.Net.CookieContainer();
    

    which made the cookies sent from the server to be resent on further requests.

    In the example above, if you call the GetGuidanceItemHtml without a valid Session cookie value you will get a security exception (there is a CAS Security demand on the server side)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a small issue in setting up speed tracer with ubuntu. any
We are using MSDTC for SQL transactions. I am having issue with setting up
I'm having an issue setting up one of my projects in TeamCity (v4.0), specifically
I am having an issue with setting the background-image of a #x to the
I'm having an issue where in my controller, I'm setting values in a collection
I'm having a strange issue with cookie visibility between an authentication servlet and our
I am having an issue trying to create a re-useable function for setting up
I am working on setting up my report server to use a web service
I'm having a bit of an issue setting up our test site. In IIS
I'm having an issue with trying to use VB.NET and the WebRequest object to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.