Set cookie in webservice request

Hi,
Is there a way to set a cookie in a webservice request or include the HttpCookie in the service call ? Basically I am using Axis on client side to call a .NET webservice on a remote server and need to pass user data to the service in a cookie.
Thanks
NK

Hi Santhiyaraman,
Webview control is in windows phone 8.1 runtime app, in windows phone 8 is webbrowser control.
Webbrowser control does not provide some properties or methods to add custom cookie, but we can do this using the javascript. Code snippet looks like the following.
private void setCookie(string name, string value, string path = "", string domain = "", bool isSecure=false, string expires = "")
var sb = new StringBuilder();
sb.AppendFormat("document.cookie = '{0}=\" + escape(\"{1}\")", name, value);
if (!String.IsNullOrEmpty(expires))
sb.AppendFormat(";expires=\"{0}\"", expires); // should be a GMTString
if (!String.IsNullOrEmpty(path))
sb.AppendFormat(";path=\"{0}\"", path);
if (!String.IsNullOrEmpty(domain))
sb.AppendFormat(";domain=\"{0}\"", domain);
if (isSecure)
sb.Append(";secure'");
var cookieJs = sb.ToString();
Debug.WriteLine(cookieJs);
webBrowser.InvokeScript(cookieJs);
You can find more information about it from
http://stackoverflow.com/questions/13287409/windows-phone-webbrowser-set-cookies.
Please try and let me know the result.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • XSQL set-cookie

    When I write an XSQL cookie, it won't actually do it until i refresh the login screen, i.e.:
    1) Enter username and password into XHTML page
    2) Post to auth.xsql
    3) auth.xsql reads the username and password and authenticates
    4) all user information for that username and password is pulled out of the database
    5) attempt at writing cookie fails.
    6) when i refresh the page, the cookie then has a value and shows up.
    Why is this? And also, is there any way of deleting the cookie, like with a logout button, using XSQL? Maybe like XSQL:delete-cookie ?
    Thanks!
    Here's the code:
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="/dvd/dvd.xsl"?>
    <database connection="dvd" xmlns:xsql="urn:oracle-xsql">
    <xsql:query id-attribute="" tag-case="lower" rowset-element="allusers" row-element="userinfo" bind-params="username password">
    SELECT *
    FROM LKUP_USER
    WHERE USERNAME = ? AND PASSWORD = ? /* AND ACCESSLEVEL = 1 */
    ORDER BY USER_ID
    </xsql:query>
    <xsql:set-cookie name="authuser" only-if-unset="no" ignore-empty-value="yes" bind-params="username password">
    SELECT USERNAME
    FROM LKUP_USER
    WHERE USERNAME = ? AND PASSWORD = ? /* AND ACCESSLEVEL = 1 */
    </xsql:set-cookie>
    <xsql:include-request-params/>
    </database>--
    Malik Graves-Pryor

    This the flat XML result when the page is first loaded:
    <?xml version="1.0" ?>
    - <!-- <?xml-stylesheet type="text/xsl" href="/dvd/dvd.xsl"?>
    -->
    - <database>
    - <allusers>
    - <userinfo>
    <user_id>1</user_id>
    <firstname>Malik</firstname>
    <lastname>Graves-Pryor</lastname>
    <username>malik</username>
    <password>malik</password>
    <email>[email protected]</email>
    <accesslevel>0</accesslevel>
    </userinfo>
    </allusers>
    - <request>
    - <parameters>
    <password>malik</password>
    <username>malik</username>
    </parameters>
    <session />
    <cookies />
    </request>
    </database>and here is what it looks like when I refresh the page, doing nothing else:
    <?xml version="1.0" ?>
    - <!-- <?xml-stylesheet type="text/xsl" href="/dvd/dvd.xsl"?>
    -->
    - <database>
    - <allusers>
    - <userinfo>
    <user_id>1</user_id>
    <firstname>Malik</firstname>
    <lastname>Graves-Pryor</lastname>
    <username>malik</username>
    <password>malik</password>
    <email>[email protected]</email>
    <accesslevel>0</accesslevel>
    </userinfo>
    </allusers>
    - <request>
    - <parameters>
    <password>malik</password>
    <username>malik</username>
    </parameters>
    <session />
    - <cookies>
    <authuser>malik</authuser>
    </cookies>
    </request>
    </database>As you can see, the cookie "authuser" is written, but only after I refresh the page. Any clues to that, and also how to delete the "authuser" cookie later on using XSQL so that one can log out of the app?
    p.s.: Steven, are you going to release an updated "Building Oracle XML Applications" book anytime within the near future, i.e., next 1-3 months?
    Malik Graves-Pryor

  • Setting cookies in a webservice doesn't work

    I am using a ColdFusion component to publish a web service
    and I want that web service to set a cookie. However, this does not
    appear to always work.
    Specifically, if I invoke the web service from the browser by
    entering a URL such as "service.cfc?method=name" in the address
    bar, then the cookie is set properly. If I use <cfinvoke> the
    cookie is not set. If I use the EasySoap C++ library then the
    cookie is set if I use <cfheader> to set it, but is not set
    if I use <cfcookie>.
    Please see the attached code samples. "cookies.cfc" is the
    component used to publish the web service, "cookies.cfm" is a
    simple test programme which invokes the web service either using
    <cfinvoke> or with the web browser (the second time you
    invoke the web service you should see that the cookies were set the
    last time you invoked it, but this only happens if you invoke it
    using the browser. A simple C++ programme to invoke the web service
    (using EasySoap, which in turn uses WinInet) returns
    "Cookie.EchoLast_2=99" meaning that only cookies set using
    <cfheader> are actually being set.
    Please explain what on earth it is doing and what is the
    correct/approved way of setting cookies in a web service.
    Thanks!

    quote:
    Originally posted by:
    MartinW-2006
    Any suggestions? AM I right in presuming this is a bug?
    Start by ensuring that your function actually runs when you
    invoke it. Does anything get returned to your calling template?

  • Getting "Set-Cookie" from response message

    Hello XI SDN'ers,
    I am calling an external webservice through my "SOAP (Axis)" adapter and I am getting the response. The response header looks like this:
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
    Set-Cookie: JSESSIONID=4DF8F0B8FAF5A1F2D7EE6A0110A33E70; Path=/
    Content-Type: text/xml;charset=utf-8
    Date: Mon, 26 May 2008 10:07:58 GMT
    Connection: close
    I want to get this "Set-Cookie" from my initial "Login" response and set the cookie in further "Synchronous Request" so that I won't loose my sessions.
    so I wrote my UDF to get this SetCookie:
    DynamicConfiguration conf = (DynamicConfiguration) container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create(
    paramNamespace, paramName);
    String value = conf.get(key);
    return myString;
    but I am getting "Null" value.
    Please correct me to get "Set Cookie" value from my response!
    Thanks & Regards,
    Satish.

    Hi,
    Check this URL for more clarification:
    help.sap.com/saphelp_nw70/helpdata/en/a6/10b98ae47ef14799a918db66ee9477/content.htm - 34k
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b092777b-ee47-2a10-17b3-c5f59380957f
    Thanks,
    Boopathi

  • Acess "set-cookie" and set later in lookup in UDF?

    Hello Experts,
    I' have a senario where I need to get a session ID in order to handle a series of web service request. Therefore I have written a UDF in the mapping where the first method (as login message) where I get a login key as payload and the session-id in the response header. This session Id then needs to be set before several other calls within the same udf are made to the webservice. We are not able to use the Axis-adapter and therefore have to use the normal SOAP-adapter.
    My question now is, is there any way to access the header of the first response message? I need to read the returned session-id and then write it to the other requests. Any idea?
    regards
    Christian

    Hi Mark,
    for sure I can post the UDF. This UDF that I have written is a generic UDF that I call from several other UDF's where ever I need to create a lookup:
    AbstractTrace trace = container.getTrace();
    String returnValue = "";
    try {
      Channel channel =  LookupService.getChannel(party,communicationComponent, communicationChannel);
      SystemAccessor accessor = LookupService.getSystemAccessor(channel);     
      InputStream inputStream = new ByteArrayInputStream(requestXMLString.getBytes());
      XmlPayload payload = LookupService.getXmlPayload(inputStream);
      Payload SOAPOutPayload = null;  
      /*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/     
      SOAPOutPayload = accessor.call(payload);   
      /* Parsing the Returnvalue     */
      InputStream inp = SOAPOutPayload.getContent();     
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();   
      /* Build DOM Structure for Input XML */     
      DocumentBuilder builder = factory.newDocumentBuilder();     
      Document document = builder.parse(inp);  
      /* Set the XML-Tag for the Response  */     
      NodeList list = document.getElementsByTagName(requestXMLValueTag);
      Node node = list.item(0);     
      if (node != null)
       node = node.getFirstChild();
       if (node != null)
        returnValue = node.getNodeValue();          
    } catch (Exception e)
      trace.addWarning("Error" + e);
    return returnValue;
    So within this function I need to access the set-cookie and then set it accordingly. If have you have any suggestions I'm very happy to hear about it.
    I don't think that I can use your link that you posted as I don't have a URLConnection-Object
    Can you show us your UDF? Maybe this blog can help:
    Simple Way to Get HTTP Response Header in Java • Crunchify
    regards
    Christian

  • How to deal with the "Set-Cookie" field in HTTP header??

    I follow the RFC-2616 specification to write a socket program to fetch web pages.
    I have to deal with all the fields included in the HTTP header.
    But the RFC-2616 doesn't talk anything about the "Set-Cookie" field.
    Does anyone know how to handle this field or provide me any useful documentation.
    Any help is appreciated.

    A cookie is set with the "Set-Cookie: "-field in the http header, like this:
    Set-Cookie: mycookie=someValue
    This cookie should only be returned to the same host as it came from, like this in the http header of a request:
    Cookie: mycookie=someValue
    If the parameter looks like this:
    Set-Cookie: mycookie=someValue; path=/cgi-bin
    , the cookie should only be returned to the host if the request path starts with /cgi-bin
    If the parameter looks liek this:
    Set-Cookie: mycookie=someValue; domain=.mydomain.com
    , the cooke should be returned to all hosts in the .mydomain.com-domain
    There is also a "expires="-field, which works as expected and a "secure"-field, which I'm not sure how to handle. Maybe the cookie should only be sent to an SSL-enabled host?
    Hope this helps you. Bye,
    Dag W.

  • How do I get and set cookies with JSF?

    How do I get and set cookies in a JSF managed bean?
    Regards,
    Al Malin

    Below is how I did it...I am receptive to improvements.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    HttpSession session = (HttpSession)facesContext.getExternalContext().getSession(false);
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
    String cookieName = "myCookieName";
    Cookie requestCookie = null;
    Cookie[] cookies = request.getCookies();
    logger.info("looking for cookie...");
    if (cookies != null)
    for (int i = 0; i < cookies.length; i++)
    if (cookies.getName().equals(cookieName))
    requestCookie = cookies[i];
    logger.info(cookieName + " = " + requestCookie.getValue());
    logger.info("done looking for cookie");
    Cookie responseCookie = new Cookie(cookieName, "myCookieValue");
    responseCookie.setPath("/");
    response.addCookie(responseCookie);

  • Set cookie

    I want to set a cookie for the username field of the login page.
    Code works this way ..
    Cookie ck1 = new Cookie("username", "this_is_a_user_id");
    response.addCookie(ck1);
    I see , this has been set in the response object !. why a cookie has to be set in the response object ? As I'm sending a request to the server , I should set the cookie in the request ...is not it ? I' think addCookie method should have been in the request object.
    Question: why cookies are set in response object instead of request object ?

    user575089 wrote:
    I have checked the link. I did not find answer to my query ...Then you haven't looked. The fact that it is held in the HTTP response header is stated quite clearly in the 2nd paragraph, and just ONE of the reasons why is in the section on Session Management, viz:
    "...A web server typically sends a cookie containing a unique session identifier. The web browser will send back that session identifier with each subsequent request and shopping basket items are stored associated with a unique session identifier..."
    However, I suggest you read the whole thing. That's what research is all about.
    Winston

  • Not able to set cookie domain ???

    Hi All,
    I am not able to set cookie domain in my webapp(WebApp.mydomain.com).
    My sample code is given below, my webapp name is WebApp.mydomain.com, this has got two jsp pages, one for creating cookie and other one is for reading the cookie.
    CreateCookie.jsp
        Cookie cookie = new Cookie("id","123");
              cookie.setDomain(".mydomain.com");
              cookie.setPath("/");
              response.addCookie(cookie);ReadCookie.jsp
    Cookie[]cks = request.getCookies();
              for(int i=0;i<cks.length;i++){
           out.print("cookie found.............................   "+cks.getValue());
    Issues:
    1. I am not able to read the cookie, if i set the domain as cookie.setDomain(".mydomain.com"); at cookie. I verified it by commenting the domain setting line.
    2. The reason for setting the domain is, I have another web application "WebApp1.mydomain.com" which is supposed to read this cookie which is created in "WebApp.mydomain.com" application.
    3. Is it possible to access the cookie across the applications as the cookie domain and path are been set. (i.e) From WebApp.mydomain.com to WebApp1.mydomain.com?Please share your inputs :(
    Thanks,
    Sundar

    Hi All,
    Any comment/solutions on this???
    Regards,
    Sundar

  • Setting cookies for safari using java

    Dear all
    I am new to cookie programming. Is there some way so that I can set cookies in Safari on Mac.
    I need to set the user's login information in cookie for a particular site then i need to launch that particular website.
    The code samples will better help. Pls help me as i am in urgent need.
    Regards
    Shobhit Jain

    Can you explain what this will do? Is this a type of
    wildcard for all domains?The answer to my question is that you can't do it, and for good reason. There is a security restriction against creating/accessing cookies from unrelated domains (and ".com" won't cut it). So I just did a complete proxy solution and translated all requests and maintained the cookies for the browser.
    I am not sure what setDomain("/") would do - I am pretty sure that is just invalid (but it is a valid path, however).

  • Set-cookie cache

    Hi All,
    If we develop the set-cookie using NSAPI on Proxy Server 4.0.2, the proxy server cache the following information.
    Request Headers
    content-length     =     165
    content-type     =     text/html
    status     =     200 OK
    Set-cookie     =     CTSESSION=AAewewedwewewew; domain=.cc.company.net; path=/
    server     =     Sun-ONE-Web-Server/6.1
    date     =     Tue, 24 Jan 2006 11:45:57 GMT
    last-modified     =     Wed, 18 Jan 2006 04:27:28 GMT
    etag     =     "a5-43cdc3b0"
    accept-ranges     =     bytes
    via     =     1.1 proxy-proxy402
    proxy-agent     =     Sun-Java-System-Web-Proxy-Server/4.0.2
    How to avoid this "Set-cookie" on cache of Proxy Server?
    regards;
    Tash

    Cannot reproduce this issue. Tried the following with 4.0.2 proxy server:
    1. Origin server sends the following response with "Set-cookie" header,
    HTTP/1.1 200 OK
    Content-length: 34
    Content-type: text/html
    Server: Sun-ONE-Web-Server/6.1
    Date: Fri, 27 Jan 2006 06:34:49 GMT
    Set-cookie: "CTSESSION=AAewewedwewewew; domain=.cc.company.net; path=/"
    Last-modified: Fri, 27 Jan 2006 06:33:33 GMT
    Etag: "22-43d9bebd"
    Accept-ranges: bytes
    Via: 1.1 S1PS
    Via: 1.1 proxy-server1
    Proxy-agent: Sun-Java-System-Web-Proxy-Server/4.0.3
    iPlanet File.
    iPlanet web server.
    2. Proxy server caches the document but without the "set-cookie" header. Following is the contents of the cached file:
    11556FFE46101FC41D     1     1138323813     0     1138323889     34
    text/html     http://dummy.com:8080/myfile8.html0014content-length0002340012content-type0009text/html0006status0006200 OK0006server0022Sun-ONE-Web-Server/6.10004date0029Fri, 27 Jan 2006 06:34:49 GMT0013last-modified0029Fri, 27 Jan 2006 06:33:33 GMT0004etag0013"22-43d9bebd"0013accept-ranges0005bytes0003via00081.1 S1PS0003via00171.1 proxy-server10011proxy-agent0038Sun-Java-System-Web-Proxy-Server/4.0.3^M
    iPlanet File.
    iPlanet web server.

  • Set Cookies in a Webbrowser control

    Hi All,
    I have a problem regarding webbrowser control in windows phone 8. I have a Native Login page in the app where we login user through service. In response of the login service we get a token.
    Now I have a page with WebBrowser control.In web browser control we open a url which has login page and dashboard. As the user is already logged in and we have the token. So we need to navigate user directly to dashboard instead of the login page.
    To do this in webbrowser control we need to set Cookies in control. How can we do this task?
    Please help me as we need to close this issue asap. Thanking you in advance.

    I have a very similar authentication flow in my app.  Using native calls (HttpClient) I am able to retrieve the authentication token, and can easily set a cookie with that token, and use the cookie with subsequent
    native calls via HttpClient.
    I believe that what you are asking for is the ability to add that cookie (with the token you got natively) into the webbrowser control's cookie store
    BEFORE trying to load your dashboard page.  You want your webbrowser control's request for the dashboard page to provide the cookie so that the user doesn't have to log
    in again, and only one webbrowser request is made.  Is this correct? 
    Sadly, I do not think this is possible.  The other answers describe how to add a cookie to a webbrowser control's page after that page has been loaded.  This is adding the cookie to the "document" within the browser control, not
    into the webbrowser control's store.  These approaches will not allow you to add the cookie into the webbrowser control's store, ahead of time, so that it will be sent when you first request the page. 
    If I am correct about what you are asking for (I want this too!) it is not supported on Windows Phone as you cannot write directly to the webbrowser control's cookie store.  You can read it, but not write to it.  It's sad as this particular
    authentication flow is very common, and easy to achieve on both iOS and Android... just not on Windows Phone.
    To get around this in my app, I perform my native authentication (HttpClient) and then authenticate
    again within the webbrowser control itself.  Basically, load the login page into the browser, then submit the login form via eval of JavaScript, and when that finishes loading (valid
    response), load the actual target page.  This is a fragile and inefficient hack, but it seems to work. 
    Hope this helps...

  • IE not set cookie for downloaded js file.Why?

    I'm trying to  download a js file from a different domain  like main page  is from  www.abc.com but js file is from www.def.com. www.def.com sets a cookie . All major browsers get the cookie and sends it in the other requests to www.def.com.But
    IE sends this cookie to www.abc.com. Cookie has also domain field set www.def.com. Any possible solution?

    How, specifically, is the cookie set?
    When you use document.cookie to set a cookie, ALL BROWSERS set the cookie in the domain in which the script runs (e.g. the page that includes it). NO BROWSERS set the cookie in the domain from which the script downloaded.
    When you use a SET-COOKIE response header to set a cookie, MOST browsers set the cookie in the domain from which the download occurs. Internet Explorer will IGNORE that cookie (not setting it anywhere) unless a P3P statement is supplied. See
    http://blogs.msdn.com/b/ieinternals/archive/2013/09/17/simple-introduction-to-p3p-cookie-blocking-frame.aspx

  • Whats happening to my set-cookie header?

    I'm writing a desktop client for a Django app running on an https domain.
    I'm attempting to retrieve cookies set by the django site when I call the site using URLRequest as follows:
    var urlVariables = new air.URLVariables();
    urlVariables.foo = "bar"
    var request = new air.URLRequest("https://www.example.com/api/foo/");
    request.data = urlVariables;
    request.method = air.URLRequestMethod.POST;
    var loader = new air.URLLoader();
    loader.addEventListener(air.HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpStatusHandler);
    loader.addEventListener(air.Event.COMPLETE, completeHandler);
    loader.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler);
    loader.load(request);
    However if I loop over the headers returned by the site like so...
    function httpStatusHandler(event){
        for(var i=0; i<event.responseHeaders.length; i++){
           air.trace(event.responseHeaders[i].name);
    ...I discover that that the Set-Cookies header is conspicuously absent.
    Is this a deliberate security restriction for calls to HTTPS sites? I'm completely baffled.
    Any help appreciated.

    Go into the System Preferences and click on Users & Groups. Try creating a new user account and then log into it to see if you have the same issues. Since your hard drive appears to be fine with plenty of space on it, and you have no major permission's issues, creating a new user for test purposes will help confirm whether you are dealing with some sort of software issue. Did you recently install some new software?
    If a new user account resolves the issue then open the Activity Monitor application located in the Applications/Utiliteis folders and click on the CPU button. In the lower left corner you should see a summary listing the % User, % System, % Idle. What are these percentages? If the CPU idle percentage is near zero then you have a process running that is consuming your SPU time. To try and find it pull down the menu to select 'All Processes', then click on the %CPU column to sort by the percent that each process is consuming your CPU.   The numbers constantly change, but do your best to see if there are one or two processes consuming the majority of the CPU time and post the names. Then do the same test in the new user account. I suspect you may have some process from a previously installed utility, virus checker, etc. that is keeping your system busy. I've included a screenshot from my system below. It doesn't have much going on, and as you can see in the lower left corner the CPU is basically idle most of the time. If I were to launch a CPU intensive app the numbers would change dramatically.

  • Why cannot I set Cookie on OAS?

    I'm using Jdeveloper3.0 and OAS4.0.8,and I make a Servlet to set cookie.The program runs perfectly in Jdeveloper,but failed on OAS.The codes are as below:
    Servlet1:
    Cookie cook=new Cookie("TestCookie","test");
    response.addCookie(cook);
    response.setContentType("text/html");
    Servlet2:
    Cookie[] cooks=request.getCookies();
    And cooks get null.However,if I use request.getHeader("Cookie"),I can get a String which contains "TestCookie=test".
    Would someone please help me?Thanks a lot.

    Sill question, but have you made sure that the path structure you are using matches the package structure for your application?
    Copying HelloWorld.class into "Folder" should not work unless the base directory is also set to "Folder". (I say this because you've indicated that the two HelloWorlds" are the same). Remember that the full name of your initial class is <package>.<className>. If this doesn't match your initclass setting then the VM will be unable to load your class.
    In general there is no particular reason why your initial class has to be at the root of the DMCC, although it is possible that the devive you are using to play out your AIT has some additional restrictions about what can be done.
    Roger

Maybe you are looking for

  • Edit in Photoshop - LR V3

    I just upgraded to LR and have a problem with Edit in Photoshop.  At about the same time I upgraded PS to CS5 and uninstalled CS4.  Now Edit in Photoshop is grayed out. My guess is it once pointed to CS4.  I have added CS5 as the second editor, but i

  • Installing iTunes 7.6

    My problem: My iPod and iTunes were working fine for months. From time to time iTunes said that it need to be upgraded and I did it and everything was still working fine, but few days ago I upgraded it and the next time I plugged my iPod it said: "Th

  • How Can I make redirect caller from agent to any branch IVR?

    I have IPCC Enterprise Edition (ICM 5.0, IVR 3.1) How can I make redirect caller from agent to chosen branch IVR, and send with call any variable to IVR (e.g. account number). Regards Krzysztof

  • SD Card reader is not reading sd card

    I have a HP ENVY Touchsmart m6 sleekbook. the hdd that came with it was damaged in a fall and had to be replaced the new hdd has Windows 7 installed on it instead of Windows 8. But all the drivers for my hardware are for Windows 8 not 7. How can i ge

  • JVM 1.5 troubles

    Hey. I have a program that when first opened it loads a JInteralFrame that has a analog clock and a pictures slide show running off of timers. My problem is when i first open the program everything loads great. If i close out my clock/slide show and