Hi Dims,
Thanks for taking some time out for my query.

I tried your build() but the whole thing seem to hang after I call
build. Nothing else happen.

I'll re- explain me problem:

1) I've got a service Skeleton generated from WSDL (No problem in that:)
2) I invoke the service and I can receive the message sucessfully and
it all works like a charm (Wonderful:)

3) I then (In my Service Skeleton Class) validate the received message
and want to fail (Because of any application logic) and as a failure I
want to throw an exception.

There comes the problem: because once the Exception is thrown from the
Service Skeleton class it goes to the
"DeliverPortMessageReceiverInOnly.java" which in turn throws Axis
fault
then it goes to the "AxisServlet "
which then calls "handleFault()"
which in turn calls "AxisEngine" "createFaultMessageContext()"
Here in this method the Header is tried to be retrieved which causes
the exception as mentioned in my Veru first mail.

Please suggest whre am I going wrong??

I'm attaching the Source for the "Skeleton" and the
"DeliverPortMessageReceiverInOnly.java" In the later one I tried to
create a SOAP fault as well unfortunately that also dosen't work.

Please advise. It is very critical to my project

Kind Regards
Amitesh



On 17/05/06, Davanum Srinivas <[EMAIL PROTECTED]> wrote:
Please try editing DeliverPortMessageReceiverInOnly.java and call a
build() on the envelope just before the call to the getHeader()
[DeliverPortMessageReceiverInOnly.java:102?]

thanks,
dims

On 5/17/06, Amitesh Pandya <[EMAIL PROTECTED]> wrote:
> Come on ! I can't believe no one has got this error???
>
> I know you've got the answer. Please let me know....
>
> Here is the problem Again.........
>
> Hi,
> I'm currently working on project and we are using Axis2 + Sandesha2
> (Both Version 1.0) for the WS-RM.
>
> One of my requirements is to return a SOAP Fault after the validation fails.
>
> I've created the service using WSDL2Java. The service works fine.
> But when I try to throw an exception (Axis Fault) from the generated
> "Skeleton" I get another Axis exception.
>
> I looked into it and it seems to be a problem with the AXIOM.
> The real problem happens when I try to call
>
> inMessage.getEnvelope().getHeader()
>
> Actually this method is called in the "AxisEngine" which is causing
> all the troubles.
>
> Please let me know if this is the known problem or If I'm missing something.
>
> Kindly suggest what is the best way of sending the Custom SOAP Fault.
>
> Your response to this query is greatly appreciated.
>
> Thanks in advance
> Amitesh
>
> Please find the attached Stacktrace:
>
> ##################################################
>
> [16/05/06 11:22:49:505 BST] 00000035 SystemErr     R
> org.apache.axiom.om.OMException
>        at 
org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:265)
>        at 
org.apache.axiom.om.impl.traverse.OMChildrenQNameIterator.hasNext(OMChildrenQNameIterator.java(Compiled
> Code))
>        at 
org.apache.axiom.om.impl.llom.OMElementImpl.getFirstChildWithName(OMElementImpl.java:222)
>        at 
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.java:76)
>        at 
uk.gov.cjse.schemas.DeliverPortMessageReceiverInOnly.invokeBusinessLogic(DeliverPortMessageReceiverInOnly.java:102)
>        at 
org.apache.axis2.receivers.AbstractInMessageReceiver.receive(AbstractInMessageReceiver.java:34)
>        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)
>        at 
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
>        at 
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>        at 
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
>        at 
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629)
>        at 
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837)
>        at 
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220)
>        at 
com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204)
>        at 
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681)
>        at 
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
>        at 
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
>        at 
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
>        at 
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
>        at 
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201)
>        at 
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103)
>        at 
com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
>        at 
com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601)
>        at 
com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
>        at 
com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
>        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)
>


--
Davanum Srinivas : http://wso2.com/blogs/

/**
 * DeliverPortMessageReceiverInOnly.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis2 version: 1.0 May 05, 2006 (12:31:13 IST)
 */
package uk.gov.cjse.schemas;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultDetail;
import org.apache.axis2.util.StreamWrapper;

import uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument;

/**
 * DeliverPortMessageReceiverInOnly message receiver
 */

public class DeliverPortMessageReceiverInOnly extends
                org.apache.axis2.receivers.AbstractInMessageReceiver {


        public void invokeBusinessLogic(
                        org.apache.axis2.context.MessageContext inMessage)
                        throws org.apache.axis2.AxisFault {

                try {

                        // get the implementation class for the Web Service
                        Object obj = getTheImplementationObject(inMessage);

                        //Inject the Message Context if it is asked for
                        org.apache.axis2.engine.DependencyManager
                                        .configureBusinessLogicProvider(obj, 
inMessage
                                                        .getOperationContext());

                        DeliverPortSkeleton skel = (DeliverPortSkeleton) obj;
                        //Out Envelop
                        org.apache.axiom.soap.SOAPEnvelope envelope = null;
                        //Find the axisOperation that has been set by the 
Dispatch phase.
                        org.apache.axis2.description.AxisOperation op = 
inMessage
                                        
.getOperationContext().getAxisOperation();
                        if (op == null) {
                                throw new org.apache.axis2.AxisFault(
                                                "Operation is not located, if 
this is doclit style the SOAP-ACTION should specified via the SOAP Action to 
use the RawXMLProvider");
                        }
                        String methodName;
                        if (op.getName() != null
                                        & (methodName = 
op.getName().getLocalPart()) != null) {

                                if ("Deliver".equals(methodName)) {

                                        //doc style
                                        skel.Deliver((DeliverDocument) 
fromOM(inMessage
                                                        
.getEnvelope().getBody().getFirstElement(),
                                                        DeliverDocument.class,
                                                        
getEnvelopeNamespaces(inMessage.getEnvelope())));
                                }
                        }
                } catch (Exception e) {
                        
                        try{
                                System.out.println("inside the Catch of the 
DeliverPortReceiverInOnly.java" ); 
                                
                                System.out.println("The FaultTo value is -- " + 
 inMessage.getFaultTo());
                                SOAPEnvelope se = inMessage.getEnvelope();
                                if(se != null){
                                        
//                                      se.build();
                                        System.out.println("Good News Envelope 
Is not Null");
                                        System.out.println("The Has Fault -- " 
+ inMessage.getEnvelope().getBody().hasFault());
                                        
                                        SOAPFactory sf = 
OMAbstractFactory.getSOAP11Factory();
                                        
                                        SOAPFault soapFault = 
sf.createSOAPFault();
                                        SOAPFaultCode sfc = 
sf.createSOAPFaultCode(soapFault);
                                        sfc.setText("SOAP-ENV:Server");
                                        SOAPFaultDetail sfd = 
sf.createSOAPFaultDetail(soapFault);
                                        sfd.setText("This is a details of the 
SOAP Fault");
                
                                        //Now add the Fault to the Body of the 
SAOP Envelope
                                        se.getBody().addFault(soapFault);
                                        
                                        System.out.println("About to get the 
Header from the Envelope");

                                        
inMessage.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, sfc);
                                        
inMessage.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, sfd);
                                        
inMessage.setProperty(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, 
"Message Format Structure is Missing");
                                        
                
                                }
                        } catch (Exception ex) {
                                System.out.println("Exception in the Catch 
itself");
                                ex.printStackTrace();
                        }
                        throw org.apache.axis2.AxisFault.makeFault(e);
                }
        }

        //
        private OMElement toOM(DeliverDocument param, boolean optimizeContent) {
                StAXOMBuilder builder = new StAXOMBuilder(OMAbstractFactory
                                .getOMFactory(), new 
StreamWrapper(param.newXMLStreamReader()));
                OMElement documentElement = builder.getDocumentElement();

                ((org.apache.axiom.om.impl.OMNodeEx) 
documentElement).setParent(null);
                return documentElement;
        }

        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
                        org.apache.axiom.soap.SOAPFactory factory,
                        
uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument param,
                        boolean optimizeContent) {
                org.apache.axiom.soap.SOAPEnvelope envelope = factory
                                .getDefaultEnvelope();
                if (param != null) {
                        envelope.getBody().addChild(toOM(param, 
optimizeContent));
                }
                return envelope;
        }

        /**
         * get the default envelope
         */
        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
                        org.apache.axiom.soap.SOAPFactory factory) {
                return factory.getDefaultEnvelope();
        }

        public org.apache.xmlbeans.XmlObject fromOM(
                        org.apache.axiom.om.OMElement param, java.lang.Class 
type,
                        java.util.Map extraNamespaces) {
                try {

                        if 
(uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument.class
                                        .equals(type)) {
                                if (extraNamespaces != null) {
                                        return 
uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument.Factory
                                                        .parse(
                                                                        
param.getXMLStreamReaderWithoutCaching(),
                                                                        new 
org.apache.xmlbeans.XmlOptions()
                                                                                
        .setLoadAdditionalNamespaces(extraNamespaces));
                                } else {
                                        return 
uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument.Factory
                                                        
.parse(param.getXMLStreamReaderWithoutCaching());
                                }
                        }

                } catch (java.lang.Exception e) {
                        throw new RuntimeException("Data binding error", e);
                }
                return null;
        }

        /**
         * A utility method that copies the namepaces from the SOAPEnvelope
         */
        private java.util.Map getEnvelopeNamespaces(
                        org.apache.axiom.soap.SOAPEnvelope env) {
                java.util.Map returnMap = new java.util.HashMap();
                java.util.Iterator namespaceIterator = 
env.getAllDeclaredNamespaces();
                while (namespaceIterator.hasNext()) {
                        org.apache.axiom.om.OMNamespace ns = 
(org.apache.axiom.om.OMNamespace) namespaceIterator
                                        .next();
                        returnMap.put(ns.getPrefix(), ns.getName());
                }
                return returnMap;
        }

}//end of class

    /**
     * DeliverPortSkeleton.java
     *
     * This file was auto-generated from WSDL
     * by the Apache Axis2 version: 1.0 May 05, 2006 (12:31:13 IST)
     */
    package uk.gov.cjse.schemas;



import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;

import uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverDocument;
import uk.gov.cjse.schemas.messages.deliver._2006_03.DeliverType;
import uk.gov.cjse.schemas.messages.format._2006_03.MessageFormatStructure;
    /**
     *  DeliverPortSkeleton java skeleton for the axisService
     */
    public class DeliverPortSkeleton{
     
        private MessageContext msgCtx = null;
        
        /**
         * 
         * @param msgCtx
         */
        public void init(MessageContext msgCtx){
                System.out.println("#####################INIT METHOD IS 
INVOKED###############");
                this.msgCtx = msgCtx;
                System.out.println("The Message Context in the Init method is 
== " + msgCtx);
        }
                 
        /**
         * Auto generated method signature
         * @param param0
         */
        public  void Deliver(DeliverDocument param0 ) throws AxisFault {
                                
                        System.out.println("By Now We Should the Message 
Context and it is === " + msgCtx);
                
System.out.println("*******%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%********");
                System.out.println("Deliver Service has been SuccessFully 
invoked");
                System.out.println("The Message Received is ======");
                System.out.println(param0);
                DeliverType dt = param0.getDeliver();
                MessageFormatStructure mfs = dt.getMessageFormat();
                
                if(mfs == null){
                        System.out.println("*************Inside the IF block 
for the MEssageFormat**");
                        
//                      SOAPFactory sf = OMAbstractFactory.getSOAP11Factory();
//                      SOAPFault soapFault = sf.createSOAPFault();
//                      
//                      SOAPFaultCode sfc = sf.createSOAPFaultCode(soapFault);
//                      sfc.setText("SOAP-ENV:Server");
//                      
//                      SOAPFaultDetail sfd = 
sf.createSOAPFaultDetail(soapFault);
//                      sfd.setText("This is a details of the SOAP Fault");
//                      
//                      
msgCtx.setProperty(SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME, sfc);
//                      
msgCtx.setProperty(SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, sfd);
//                      
msgCtx.setProperty(SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME, "Message 
Format Structure is Missing");
                        
                        throw new AxisFault("This is the Reason For Exception", 
"this is fault Code");
                }
                
System.out.println("*******%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%********");
        }
    }
    

Reply via email to