Adding to JAX-WS 2.1 response object's header

Hello
We are using JAX-WS 2.1. We have a requirement to have few fields such as userId to be part of SOAP response's header. How to have these added in the header. Using @WebResult(header=true) gets the whole result object into the header which I don't want

Any suggestions

Similar Messages

  • Adding responsibility objects for the Notification Groups for a PA

    Hi Gurus,
    I am supposed to add responsibility objects for the notiifcation groups for a PA.. Could you please confirm the steps I am planning to follow
    1. Find out the Workflow
    2. Add the responsibilities objects ( Where can Add  those ( in the workflow or in Org Management?)
    3. Edit the rule to point to that PA..
    I am new to workflows ..points are assured for the help

    Just write your own composite Icon class:
    public class CompositeIcon implements Icon
      private Icon icon1;
      private Icon icon2;
      public CompositeIcon(Icon icon1, Icon icon2)
        this.icon1 = icon1;
        this.icon2 = icon2;
      public int getIconHeight()
        return Math.max(icon1.getIconHeight(), icon2.getIconHeight());
      public int getIconWidth()
        return icon1.getIconWidth() + icon2.getIconWidth();
      public void paintIcon(Component c, Graphics g, int x, int y)
        icon1.paintIcon(c, g, x, y);
        icon2.paintIcon(c, g, x + icon1.getIconWidth, y);
    }Hopefully a slightly more reusable solution. You could write all sorts of different layouts in this way.
    Hope this helps.

  • Two response objects within one servlet...

    Heya guys, quite new to java and got stuck for the whole day on this.
    I need to combine two responses inside one servlet. One response retrieves picture from the database and it works fine. Another one retrieves text from database also works fine on its own. Second i try to use both end up with hundreds of exceptions.
    Any idea what to do, not how...but what???
    Thanks

    Compiling 1 source file to F:\gopal\weba\WebApplication6\build\web\WEB-INF\classes
    F:\gopal\weba\WebApplication6\src\java\NewServlet.java:48:
    processRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletResponse) in NewServlet cannot be applied to (javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    processRequest(request, response);
    F:\gopal\weba\WebApplication6\src\java\NewServlet.java:57: processRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpServletResponse) in NewServlet cannot be applied to (javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    processRequest(request, response);
    2 errors
    F:\gopal\weba\WebApplication6\nbproject\build-impl.xml:295: The following error occurred while executing this line:
    F:\gopal\weba\WebApplication6\nbproject\build-impl.xml:149: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 2 seconds)
    You cannot use two response object.

  • Response object in JSP Dyn page

    Hi SAP EP Gurus,
    I want to use response.setStatus() mehtod in jspdynpage but it is not working as expected. I am able to use other methods of response object like response.write().
    As per my knowledge if i set response.setStatus(200) is should send error to client but it is not seding error.
    It is working as same for both response.setStatus(200) and response.setStatus(500).
    Is there any special way to use response.setStatus() in portal? It is working as expected in normal jsp application.

    I tried but had no luck. Below is my JSPDYNPAGE code...
    <%@ page import="javax.servlet.http.HttpServletResponse" %>
    <%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
    <HTML>
         <head>
         </head>
         <body>
    <%
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    HttpServletResponse servletResponse = request.getServletResponse(true);esss
    servletResponse.setStatus(500);
    %>
              </body>
         </HTML>
    It is not working showing portal run time error

  • WebService response object in XML - parsing attributes

    Hi- new to Flex and I'm trying to parse out the attributes of the response object. I can get the entire object and see that its working, but I cant get just a single attribute. It pulls weather info for world cities. For example, I just want the location name and temperature.
    Any advice on this? Thanks!
    <?xml version="1.0"?>
    <!-- fds\rpc\RPCResultFaultMXML.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    xmlns:s="library://ns.adobe.com/flex/spark">
        <mx:Script>
            <![CDATA[
                import mx.rpc.soap.SOAPFault;        
                import mx.rpc.events.ResultEvent;
                import mx.rpc.events.FaultEvent;
                import mx.controls.Alert;
                import mx.utils.ObjectUtil;
                public function showErrorDialog(event:FaultEvent):void {
                    // Handle operation fault.
                    Alert.show(event.fault.faultString, "Error");
                public function defaultFault(event:FaultEvent):void {
                    // Handle service fault.
                    if (event.fault is SOAPFault) {
                        var fault:SOAPFault=event.fault as SOAPFault;
                        var faultElement:XML=fault.element;
                        // You could use E4X to traverse the raw fault element returned in the SOAP envelope.
                    Alert.show(event.fault.faultString, "Error");              
                public function log(event:ResultEvent):void {
                    // Handle result.
                    trace(event.result);
                    //trace(ObjectUtil.toString(event.result));
                    //var len:int;
                    //len = event.result.length;
                    //trace(len);
                    //trace(event.result);
                    //trace(event.result.GetWeatherResponse.Location);
                    //var myXML:XML = new XML(event.result);
                    //trace(myXML.attribute("Location"));
            ]]>
        </mx:Script>
        <mx:WebService id="WeatherService" wsdl="http://www.webservicex.com/globalweather.asmx?wsdl"
                       fault="defaultFault(event)">
            <mx:operation name="GetWeather"
                          fault="showErrorDialog(event)"
                          result="log(event)"
                          resultFormat="xml">
                <mx:request>
                    <CityName>{myCity.text}</CityName>
                    <CountryName>{myCountry.text}</CountryName>
                </mx:request>
            </mx:operation>
        </mx:WebService>
        <mx:TextInput id="myCity" text="Madrid"/>
        <mx:TextInput id="myCountry" text="Spain"/>
        <!-- Call the web service operation with a Button click. -->
        <mx:Button width="60" label="Get Weather"
                  click="WeatherService.GetWeather.send();"/>
        <!-- Display the Weather -->
        <mx:Label text="Weather:"/>
        <mx:TextArea text="{WeatherService.GetWeather.lastResult}" height="200"/>
    </mx:Application>

    The WSDL says GetWeatherResponse is a string, and it appears to be a string of XML, so set <mx:operation resultFormat="object"> as this will unwrap the SOAP response value and leave a string typed value intact. You can then create a new ActionScript 3.0 E4X-based XML instance from the unwrapped string:
        var myXML:XML = new XML(event.result.toString());
    You can then travese the XML document using E4X syntax, a simple example is included below:
        trace(myXML..Location);
        trace(myXML..Temperature);

  • Error with response object in Portal Application Module

    Hi,
    i have a portal application project in NWDS, with a JspDynpage component. I have a jsp that contains this code:
    OutputStream os = componentResponse.getServletResponse().getOutputStream();
    response.addHeader("Content-Disposition", "attachment;filename=" + sTITLE +".pdf");
    response.setContentType("application/pdf");
    os.write(contenido);
    os.close();
    this code open a pdf in new window. In web module project that app runs correctly but in portal application no, it fails in object response. the log (in default trace) doesn´t help me nothing, only sais:
    Jun 6, 2011 3:19:55 PM     com.sap.portal.prt.runtime.servlet_jsp [SAPEngine_Application_Thread[impl:3]_13] Error: >>> JSPCompiler >>> ERROR in Compiling :JSPFileInfo :314221189
    JSP File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/pagelet/inicio.jsp
    Class Name: sapportalsjspInicio
    Java File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/work/pagelet/_sapportalsjsp_inicio.java
    Package Name : pagelet
    Class File : /usr/sap/DP4/DVEBMGS40/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/appl.factdist.efact.por/work/pagelet/_sapportalsjsp_inicio.class
    Is out dated : false [email protected]bbc2b
    In addition, i can use the request object perfectly
    somebody knows what's happening??
    Thank you,
    Fernando

    Hi,
    You shouldn't use the response object directly
    Instead, create a new HttpServletResponse reference from the componentRequest object.
    Try using the following:
    long length = file.length(); // where 'file' is a File() object of your sTITLE +".pdf" file
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
        offset += numRead;
    //The most important part:
    HttpServletResponse res = componentRequest.getServletResponse(true);
    res.setContentType("application/pdf");
    res.addHeader("Content-Disposition", "attachment;filename=" + sTITLE +".pdf");
    res.getOutputStream().write(bytes);

  • HTTP request/response object not thread safe.

    According to the serlvet spec. Http Request/Response
    are not thread safe. Quoting from the Spec:
    " Implementations of the request and response objects are not guaranteed to be thread safe. This means that they should only be used within the scope of the request handling thread. References to the request and response objects must not be given to objects executing in other threads as the resulting behavior may be nondeterministic."
    This has prompt me to ask the following question.
    For Example I have a servlet which does the following
    request.setAttribute("myVar","Hello");
    The request and response is dispatched(using RequestDispatch.include(request,response)) to another
    servlet which retrieve this attribute i.e request.getAttribute("myVar");
    Is this safe?
    The Spec only said "The Container Provider must ensure that the dispatch of the request to a target
    servlet occurs in the same thread of the same VM as the original request." I take this meaning that the targeting servlet does not have to run in the same thread(only dispatch), otherwise it would be safe.

    To put it another way, you can only have onle thing working on a request at a time. For instance, the ServletContext is available to all servlets running on a server. If you tried to save a particular request to the ServletContext, it would potentially be available to many concurrently running servlets. They could all change whatever in it at the same time. Each servlet is in its own running thread. Hope that helps some.

  • Web service response object contains no values

    Hi,
    Using Netweaver, I've created an EJB-based web service that contains a single method. The method takes two input parameters and returns as a response, a data transfer object (DTO) containing several boolean values.  When I test this web service with the Web Service Navigator however, the response object contains a flat DTO-- meaning the contents of the DTO are missing. For example, this is what happens now when I call the web
    service...
    Incoming parameters:
    ...userID (String) = some user ID
    ...systemID (String) = some system ID
    Outgoing parameters:
    ...response
    ......(nothing contained within response--
    ...... there should be boolean values here)
    But this is what I should see when I call the web service...
    Incoming parameters:
    ...userID (String) = some user ID
    ...systemID (String) = some system ID
    Outgoing parameters:
    ...response
    ......booleanValue1
    ......booleanValue2
    ......booleanValue3
    Documentation doesn't seem to address this problem. Does anyone know how to correct this?
    Thanks,
    Amy

    Hi
    Have you found the workaround?
    Sorry for refreshing topic. Flag mustUnderstand ='1' in response is unussual thing.
    BR

  • Does any one implemented solution for httpservlet request/response object in IWSDLInterceptor implemented class?

    I am trying to handle Producer not available situation in which I am using Interceptor IWSDLInterceptor in WLP 10.3.4. I am able to retrieve exception using onWSDLException but from here if I have to forward my pageURL object I need httpservlet request and response. I tried my own filter class to have its own customize request and also tried it out all other Interceptor to see if any one can handle IOException. I did manage to throw my own Customize exception but  that also did not work out as Page does not have any backing file or any supportive Controller class.
    Does any one implemented solution for httpservlet request/response object in IWSDLInterceptor implemented class? or do we have any specific documentation in regards to this? As I am not able to find much martial on IWSDLInterceptor except Java API from Oracle and article defining Two way SSL handshake Producer.
    Any kind of help is appreciated.
    Thanks
    PT

    Thanks Emmanuel for your response but render behavior is not available for IWSDLRequestContext/IWDSLResponseContext object which IWSDLInterceptor uses for implementation.
    Let me put my question in little simpler manner. May be my approach to the problem is not proper.
    Problem : Handle Producer Not available (no application exists on server) on consumer side.
    So far tried approach : Producer is not running then I am able to handle that TransportException at IInitCookieInterceptor/IHandleEventInterceptor onFault behaviour but in the case of Producer not even exists Consumer try to get WSDL fetch operation and failed with FileNotFoundException.
    To handle this exception, I used IWSDLInterceptor which is available under IWSDLInterceptor.OnWSDLException (Oracle Fusion Middleware Java API for Oracle WebLogic Portal)
    I am able to catch the exception but problem arise when application needs to forward at specific page/render portlet for this situation. For that it required request/response object but IWSDLInterceptor does not give any kind of instances to redirect request as there is no direct access to HTTPServlet request/response object.
    I tried my custom request object to use there. I tried out custom filter object of IWSDLrequestContext. nothing works.
    One approach works is to put producer WSDL file at consumer level. But in that, you need to handle different producer files for different environment. Which I don't think its a good approach.
    eAny one Let me know if my approach to the problem/scenario is wrong. Or if I am missing out any other supporting interface which also required to handle this scenario. or I am using wrong interface for this scenario.
    Thanks for your help in advance.
    PT.

  • URGENT! Can response object contain text as well as binary data

    hi all,
    My test scneario is like this..
    a) User is having a button "Download File" i will call this as download.jsp
    b) After hitting the download button i will be sending the file to user by writting into the ServletOutputSream.
    c) Whatever option user chooses (i.e. Save / Open / Cancel) I want to do some updations on the existing user screen.
    Maybe presenting him the download status e.g. "File Downloaded"
    The problems i am facing are
    1. SInce i am using ServletOutputSream once i flush the stream i loose the control on response object.
    2. After user's operation (i.e. Save / Open / Cancel) unless user again hits
    something on UI my server has to look at him with dumb eyes. :(
    3.The download operation that i am performing expects some attributes from the request ..
    they are Object attributes and not string attribute so i cant user URL rewritting.
    If anybody has encountered this type of problem in there projects please share the workaround you used.
    Thanx a lot
    --Bhupendra Mahajan

    Here in order to send the file to Client i must use Stream ... and in prder to
    update the status i.e. HTML i must use Printwritter.... That is the reason
    i need both ... If you have some OutputStream available deep down somewhere you can use
    both; it just takes a bit of discipline:OutputStream ros; // available from somewhere
    // use the following stream for your binary output:
    BufferedOutputStream bos= new BufferedOutputStream(ros);
    // and use this one for your PrintWriter:
    PrintWriter pw= new PrintWriter(bos);Everytime before you want to print some binary data, flush the pw, and everytime
    before you want to print some text data, flush the bos.
    kind regards,
    Jos

  • Creating a response object

    Hi,
    I have the following case. I am intiliazing all the variables in the init() method of the servlet using a resoruce bundle.
    I want to put a condition in init() by which it cannot get the resource bundle then the user should get directed to an error page.
    I know that it is acheieved by response.sendRedirect("error.jsp");
    But how can i create the response object.
    Regards
    sandeep

    hi sandeep,
    i think we can't get the request or response objects in init() method,
    so we can't redirect to the any other page in init() method.
    regards,
    sekhar

  • Request and Response Objects

    Hi,
    I was told that there is a limit for the request and response object sizes and crossing them will throw IllegalStateException. Could some one explain whether this is true and what is the maximum size of the object allowed?
    Thanks,
    Des

    As far as I know no such limit is defined by the API. There will always be a limit due to implementation and underlying architecture. Which particular implementation of request/response are you concerned about?

  • Getting response object field value as null when importing xsd file in wsdl

    I have created a java webservice using X-Fire 1.2.6 framework and deployed on Tomcat 6.0 server. The response of the service is a java object named LoginDetail.
    Inorder to reuse the basic elements and types we have defined them in a separate Types.xsd file which have been imported in the WSDl file using xsd:import by giving the path to the xsd file.
    Below you can see the portion of the wsdl file
         <wsdl:types>
              <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   attributeFormDefault="qualified" elementFormDefault="qualified"
                   targetNamespace="http://webservices.gtl.de/xsd">
                   <xsd:import namespace="http://webservices.gtl.de/xsd"
                        schemaLocation="file:///D:/wsdl/LoginTypes.xsd"></xsd:import>
              </xsd:schema>
         </wsdl:types>
    After deploying the application on Tomcat I could access the WSDL using a web browser and after that I could successfully generate webservice client code using using XFire wsgen ant build.
    But when tried to call the service the fields of the response object(in my case it is LoginDetail object) returns null.
    Follwing are the main class used for running the client and the output received as webservice respone.
    Main class
    public static void main(String[] args) {
    CCLoginNewClient client = new CCLoginNewClient();
    CCLoginNewPortType service     = client.getCCLoginNewHttpPort();                         
    LoginDetail loginDetail = service.getLogin("CCLoginNew", "DE", "DE", "100", "0", "CC", "15","9344");
    System.out.println("service got in response : "+loginDetail.getService());                    
    Output
    service got in response : null
    is this the right way to import an xsd file in a wsdl file?
    Any input would be appreciated!
    Thanks in advance

    PramodDas wrote:
    Output
    service got in response : nullCheck with Apache TCPMonitor what response you are receiving from web service.
    is this the right way to import an xsd file in a wsdl file?Make sure that you really need import, not the include. However, I guess it has nothing do with the actual issue. It just to make sure that you are using right option.

  • How to send an object thru "response" object

    I need to send an object to a servlet thru my jsp page.
    When I created an ObjectOutputStream passing response.getOutStream as parameter, I am getting an IllegalStateException. I have checked that the response object is not being used anywhere else.
    Please help me out.
    Thanks a ton

    Try this and let me know
    try {
    ObjectOutputStream p = new                          ObjectOutputStream(
         response.getOutputStream() );
    p.writeObject("what ever object");
    p.flush();
    p.close();
    }catch (Exception e) {
    e.printStackTrace();
    I use this in my code and it works perfectly. If it still does not work, send me the entire code that you have written and I shall try to look into it and see whats going wrong.
    --ramsci                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using Request,response objects

    these are the 2parts of my code in Dotnet,i have to convert it into java
    1) request.ContentType = "application/x-www-form-urlencoded";
    // Set the content length of the string being posted.
    request.ContentLength = postByte.length;
    2) response = (HttpWebResponse)request.GetResponse();
    stream = response.GetResponseStream();
    i am trying the above using HttpServletRequest request,but i am not able to do
    can any body suggest this
    Thanks in Advance

    What are you trying to do? The method you want to call will be probably be on the response object: setContentType(), setContentLength(), and for the stream to read: request.getServletInputStream() or stream to write out: response.getOutputStream.
    It depends what you are trying to do really. You should be able to get those objects (request and response) from your servlet methods like "processRequest(HttpServletRequest request, HttpServletResponse response)".
    Hope that this helps you a little.

Maybe you are looking for