[
http://issues.apache.org/jira/browse/AXIS2-801?page=comments#action_12415169 ]
John Grantham commented on AXIS2-801:
-------------------------------------
Hi --
I am having trouble with custom exceptions that is the same issue, i think. I
am using WSDL2Java, with a custom fault.
This is my WSDL (original, not the ugly version that ends up in /resources):
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="AddressRetrieval"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:key="http://nextgen.ubc/schema/StudentKey"
xmlns:addr="http://nextgen.ubc/schema/Address"
xmlns:err="http://nextgen.ubc/schema/Error"
xmlns:service="http://nextgen.ubc/wsdl/AddressRetrieval"
targetNamespace="http://nextgen.ubc/wsdl/AddressRetrieval">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://nextgen.ubc/schema/StudentKey"
schemaLocation="schemas/StudentKey.xsd"/>
<xsd:import namespace="http://nextgen.ubc/schema/Address"
schemaLocation="schemas/Address.xsd"/>
<xsd:import namespace="http://nextgen.ubc/schema/Error"
schemaLocation="schemas/Error.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="AddressRequest">
<wsdl:part element="key:StudentKey" name="AddressRequest" />
</wsdl:message>
<wsdl:message name="AddressResponse">
<wsdl:part element="addr:Address" name="AddressResponse" />
</wsdl:message>
<wsdl:message name="StandardError">
<wsdl:part element="err:Error" name="StandardError" />
</wsdl:message>
<wsdl:portType name="AddressRetrieval">
<wsdl:operation name="getAddress">
<wsdl:input message="service:AddressRequest" />
<wsdl:output message="service:AddressResponse" />
<wsdl:fault message="service:StandardError" name="StandardError" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AddressRetrievalSOAPBinding"
type="service:AddressRetrieval">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getAddress">
<soap:operation
soapAction="http://nextgen.ubc/wsdl/operation/getAddress" />
<wsdl:input>
<soap:body parts="AddressRequest" use="literal"
/>
</wsdl:input>
<wsdl:output>
<soap:body parts="AddressResponse"
use="literal" />
</wsdl:output>
<wsdl:fault name="StandardError" >
<soap:fault name="StandardError"
encodingStyle="http://schemas/xmlsoap.org/soap/encoding" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AddressRetrievalService">
<wsdl:port binding="service:AddressRetrievalSOAPBinding"
name="AddressRetrieval">
<soap:address
location="http://www4.students.ubc.ca:9180/axis2/services/AddressRetrievalService"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
---------------------------------------
This is my skeleton code which given a particular input value will throw the
custom "StandardErrorException":
/**
* AddressRetrievalServiceSkeleton.java This file was auto-generated from WSDL
* by the Apache Axis2 version: 1.0 May 04, 2006 (09:21:04 IST)
*/
package ubc.nextgen.wsdl.addressretrieval;
import ubc.nextgen.schema.address.Address;
/**
* AddressRetrievalServiceSkeleton java skeleton for the axisService
*/
public class AddressRetrievalServiceSkeleton
implements AddressRetrievalServiceSkeletonInterface {
/**
* Auto generated method signature
*
* @param param2
*/
public ubc.nextgen.schema.address.Address getAddress(
ubc.nextgen.schema.studentkey.StudentKey param2)
throws
ubc.nextgen.wsdl.addressretrieval.AddressRetrievalServiceSkeleton.StandardErrorException
{
if (param2.getStudentNumber().equals("11111111")) {
throw new RuntimeException();
}
else if (param2.getStudentNumber().equals("22222222")) {
throw new StandardErrorException();
}
else {
Address address = new Address();
address.setStudentNumber("12345678");
address.setStreet("1234 Happy Lane");
address.setCity("Pleasantville");
address.setProvince("BC");
address.setPostalCode("V6J2G4");
return address;
}
}
public static class StandardErrorException extends java.rmi.RemoteException
{
private ubc.nextgen.schema.error.Error faultMessage;
public void setFaultMessage(ubc.nextgen.schema.error.Error msg) {
faultMessage = msg;
}
public ubc.nextgen.schema.error.Error getFaultMessage() {
return faultMessage;
}
}
}
-------------------------------
My generated stub does not throw the custom exception (i get an AxisFault
without useful details), and the format of the SOAP fault over the wire looks
like this:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header />
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>StandardErrorException</faultstring>
<detail>
<Exception>org.apache.axis2.AxisFault: StandardErrorException
at
ubc.nextgen.wsdl.addressretrieval.AddressRetrievalServiceMessageReceiverInOut.invokeBusinessLogic(AddressRetrievalServiceMessageReceiverInOut.java:63)
at
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:480)
at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)
</Exception>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
----------------------------------------------
I would expect the SOAP message carrying the fault to contain my custom
exception fields somewhere, would i not?
In any case, does this appear to be the same bug??
> UserException -> AxisFault is not put in details to the SOAP-response ++
> Davanum advised me to open an issue
> ------------------------------------------------------------------------------------------------------------
>
> Key: AXIS2-801
> URL: http://issues.apache.org/jira/browse/AXIS2-801
> Project: Apache Axis 2.0 (Axis2)
> Type: Bug
> Components: transports
> Versions: 1.0
> Environment: WinXP Prof, JDK 1.4.2_09,Tomcat 5.0.28,
> Reporter: Bille
> Assignee: Eran Chinthaka
>
> Service works fine in normal use. I did not use code-generation with WSDL; I
> created it manually.
> When one parameter for the service is not usable, the service should throw a
> KIDnotFoundException, which then should be transported with all its details
> as a SOAPFault in the response to the client.
> ------------------------- my UserException -----------------
> import java.rmi.RemoteException;
> public class KIDnotFoundException extends RemoteException {
> public KIDnotFoundException(String message, Throwable ex){
> super(message, ex);
> }
> }
> ------------------------- my service implementation -----------------
> import de.eonis.bd.ws.util.*;
> import java.util.*;
> import java.util.logging.Logger;
> import javax.naming.NamingEnumeration; // JDK
> import javax.naming.NamingException;
> import javax.naming.directory.*;
> import javax.xml.namespace.QName; // aus stax-api-1.0.jar
> import org.apache.axiom.om.*; // aus axiom-api-1.0.jar
> import org.apache.axiom.soap.*;
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.context.*;
> import org.apache.axis2.context.*;
> import org.apache.axis2.wsdl.WSDLConstants;
> public class LDAPQueryService {
> private LDAPQuery ldapQuery = null;
> private MessageContext inMsgCtx = null;
> private MessageContext outMsgCtx = null;
>
> // Konstanten fuer die Market-Units (MU)
> public static final String MU_EAG = "eonag";
> public static final String MU_EEA = "eea";
> public static final String MU_ERG = "ruhrgas";
> public static final String MU_NOR = "eno";
> public static final String MU_UK = "eonuk";
> public static final String MU_US = "lgee";
> public static final String MU_ALL = "global";
> // lasse ich init(param in) und setOperationConext drin erhalte ich den
> Fehler beim Starten des Tomcat
> /**
> * - Error in schema generating Sorry we don't support methods
> overloading !!!!
> java.lang.Exception: Sorry we don't support methods overloading !!!!
> at
> org.apache.ws.java2wsdl.SchemaGenerator.generateSchema(SchemaGenerator.java:143)
> at
> org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:213)
> at
> org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:149)
> at
> org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:76)
> at
> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:118)
> at
> org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:620)
> ....
> */
> /*
> public void init(MessageContext msgCtx){
> System.out.println("setting MessageContext: " + msgCtx.toString());
> this.MsgCtx = msgCtx;
> }
> /**
> public void init(MessageContext inCtx, MessageContext msgCtx){
> System.out.println("setting outgoing MessageContext: " +
> msgCtx.toString());
> this.msgCtx = msgCtx;
> }
>
> **/
>
> /**
> * Das geht
> * aus : http://marc.theaimsgroup.com/?l=axis-user&m=114715486422557&w=2
> */
> public void setOperationContext(OperationContext opctx) throws
> AxisFault {
> System.out.println("setting in- & outgoing MessageContext: " +
> opctx.toString());
> this.inMsgCtx =
> opctx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
> this.outMsgCtx =
> opctx.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
> }
>
>
> /**
> * Liefert die Gruppen eines Users im EONGDS, dh fuer alle moeglichen
> MUs.
> * Die MU des Users kann noch mit uebergeben werden, dann wird auch nur
> in diesem Container
> * nach dem User gesucht.
> *
> * Das EONGDS ist aktuell noch nicht soweit mit dem GDir
> synchronisiert, dass darueber
> * alle MUs abbildbar waeren.
> * Zur Zeit enthalten GDir und EONGDS nicht die gleichen Gruppen.
> *
> * @param kid String die eindeutige Konzern-ID des Users.
> * @param mu String Kuerzel fuer die zu durchsuchende MU
> */
> public OMElement getEONGDSGroups(OMElement input) throws AxisFault {
> // String kid, String marketUnit
> String method = "getEONGDSGroups()";
> // fully qualified Names
> QName kidName = new QName(OMHelper.NAMESPACE, "kid");
> String kid = input.getFirstChildWithName(kidName).getText();
> QName muName = new QName(OMHelper.NAMESPACE, "mu");
> String mu = input.getFirstChildWithName(muName).getText();
> System.out.println("Up to search EONGDS-Groups for KID " + kid + " in MU " +
> mu);
>
> OMElement result;
> if (Utils.isValidKID(kid)){
> try {
> System.out.println("up to query directory...");
> ldapQuery = new LDAPQuery(false,
> LDAPQuery.EONGDS, "o=eon,c=de");
> // nur Groupmembership-Attribut ist relevant
> ldapQuery.setReturnAtts(new String
> []{"groupmembership"});
> String base = "ou=users,ou=" + mu +
> ",o=eon,c=de";
> String filter = "(&(cn=" + kid +
> ")(objectClass=person))";
> NamingEnumeration data =
> ldapQuery.querySubtree(base, filter);
> result = OMHelper.getSOAPFromLDAPResult(data);
> }
> catch (NamingException ne){
> result = null;
> System.out.println("getEONGDSGroups throws NamingException: " +
> ne.getMessage());
> SOAPFactory soapFactory =
> OMAbstractFactory.getSOAP12Factory();
> SOAPFault soapFault =
> soapFactory.createSOAPFault();
> SOAPFaultCode faultCode =
> soapFactory.createSOAPFaultCode(soapFault);
>
> faultCode.declareNamespace("http://someuri.org", "m");
> SOAPFaultValue soapFaultValue =
> soapFactory.createSOAPFaultValue(faultCode);
> soapFaultValue.setText("m:FaultException");
> SOAPFaultReason soapFaultReason =
> soapFactory.createSOAPFaultReason(soapFault);
> SOAPFaultText soapFaultText =
> soapFactory.createSOAPFaultText(soapFaultReason);
> soapFaultText.setText("the reason of the
> error");
>
> // setting the outgoing MessageContext
>
> outMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, faultCode);
>
> outMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME,
> soapFaultReason);
>
> //outMsgCtx.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME,
> faultDetail);
>
> // throw the AxisFault
> throw new AxisFault("Exception in
> service-method :: getEONGDSGrous()", ne);
> }
> }
> else {
> String text = "invalid KID: KID' " + kid + "' not found
> in MU '" + mu + "'";
> result = handleInvalidData(text, method);
> }
>
> return result;
>
> }
> // ... some more service-methods ...
> }
> ------------------------- the SOAP response -----------------
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header />
> <soapenv:Body>
> <soapenv:Fault>
> <faultcode>soapenv:Client</faultcode>
> <faultstring>unknown</faultstring>
> <detail>
> <Exception>
> org.apache.axis2.AxisFault
> at
> org.apache.axis2.receivers.RawXMLINOutMessageReceiver.invokeBusinessLogic(RawXMLINOutMessageReceiver.java:102)
> at
> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)
> 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:709)
> at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
>
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
>
> at
> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
> ....
> </Exception>
> </detail>
> </soapenv:Fault>
> </soapenv:Body>
> </soapenv:Envelope>
> ------------------------- SOAPFault manually built -----------------
> The following is set to the outgoing messageContext in my
> serviceimplementation - outMsgCtx.setProperty():
> <soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
> <soapenv:Code xmlns:m="http://someuri.org">
> <soapenv:Value>m:FaultException</soapenv:Value>
> </soapenv:Code>
> <soapenv:Reason>
> <soapenv:Text>the reason of the error</soapenv:Text>
> </soapenv:Reason>
> </soapenv:Fault>
> ------------------------- issues I wonder about -----------------
> 1) My details aren't reaching the client. The following I found out while
> debugging the service:
> In class RawXMLINOutMessageReceiver::invokeBusinessLogic() my service-method
> is called and throws an exception as expected. The exception is of type
> InvocationTargetException and has as a member variable called "target" an
> object of type AxisFault, with the detailvariable set to the originally
> thrown exception and the detailmessage set to my individuel errormessage.
> The invokeBusinessLogic() catches this exception and throws an AxisFault
> using mentioned InvocationTargetException, like this:
> throw new AxisFault(e.getMessage());
> The message member of the InvocationTargetException is null !! so all my user
> definitions are gone.
> 2) The above depicted response looks like SOAP 1.1 and not 1.2. I thought
> Axis2 would work with SOAP 1.2 per default ?
> 3) In addition the faultCode says CLIENT !!!
> 4) I could access the messageContext only by setOperationContext(). I
> formerly tried the init(param1); if so I get a serious error while starting
> the server:
> - Error in schema generating Sorry we don't support methods overloading
> !!!!
> java.lang.Exception: Sorry we don't support methods overloading !!!!
> at
> org.apache.ws.java2wsdl.SchemaGenerator.generateSchema(SchemaGenerator.java:143)
> at
> org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:213)
> at
> org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:149)
> at
> org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:76)
> at
> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:118)
> at
> org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:620)
> Maybe I'm missing something; unfortunately I could not find any sample for
> using UserExeptions the right way.
> Could someone clear these issues please - Thanks a lot
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]