You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Robert Ribnitz <ro...@unifr.ch> on 2008/05/16 15:48:50 UTC
AXIS2 1.4: Client problems when changing form plain XML to SOAP-style
messages: Disallowed element found in envelope:Envelope..
Hello,
I have also posted the following to the user list, with no response. As
I think this might be an error in Axis2, I am forwarding this to the dev
list.
I have recently started to use AXIS2 (1.4) (on J2EE 5/with the Sun Java
Application Server 9.1, using Java 6); the idea is to be able to create
SOAP-based webservices to rsolve certain problems.
Using plain AXIOM to generate client replies (these are generated based
on Database input) is not too hard; client and server side work fine.
However, as soon as i try to switch to SOAP basded Messaging, things go
wrong; i get the exception as listed below
This has probably been asked times and ties before.
Can anyone tell me what I a doing wrong?
Robert Ribnitz
org.apache.axiom.soap.SOAPProcessingException: Disallowed element found
inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Envelope
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:298)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:212)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:191)
at
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
at
org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:633)
at
org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:141)
at
org.apache.axiom.om.impl.llom.OMElementImpl.getFirstElement(OMElementImpl.java:961)
at
org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.java:84)
at
org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:74)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:166)
at
org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
at
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at
org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at
org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at
diuf.pai.flexmobile.dbwebservices.client.FlexMobilePointGetter.getPointsFromWebService(FlexMobilePointGetter.java:73)
(more stacktrace)
The relevant client code is:
private final static EndpointReference EPR=new EndpointReference(
//
"http://localhost:8080/axis2/services/FlexMobilePointGetterService"
"http://localhost:8080/axis2/services/FlexMobilePointGetterService"
);
@SuppressWarnings("unchecked")
protected void getPointsFromWebService() {
try {
final ConfigurationContext
ctx=ConfigurationContextFactory.createDefaultConfigurationContext();
final ServiceClient theClient=new ServiceClient(ctx,null);
final Options opts=new Options();
opts.setAction("urn:getPoints");
opts.setTo(EPR);
opts.setTransportInProtocol(Constants.TRANSPORT_HTTP);
opts.setProperty(Constants.Configuration.ENABLE_REST,
Constants.VALUE_FALSE);
theClient.setOptions(opts);
final OperationClient mepClient =
theClient.createClient(ServiceClient.ANON_OUT_IN_OP);
final MessageContext mc = new MessageContext();
final SOAPFactory sf=OMAbstractFactory.getSOAP11Factory();
final OMNamespace
ns=sf.createOMNamespace("http://dbwebservices.flexmobile.pai.diva/xsd",
"PointReq");
final OMElement elem=sf.createOMElement("getPointsRequest",ns);
final SOAPEnvelope env=sf.getDefaultEnvelope();
env.getBody().addChild(elem);
mc.setEnvelope(env);
mepClient.addMessageContext(mc);
mepClient.execute(true); // This is line 73
final MessageContext response =
mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
final SOAPBody body = response.getEnvelope().getBody();
final OMElement result=body.getFirstElement();
// final OMElement result=theClient.sendReceive(elem);
thePointList.clear();
final Iterator<OMElement>
resultChildrenIterator=result.getChildrenWithLocalName("getPointsResponse");
// filling in the thePointList using the iteator
// now everything is in a List,
} catch (final AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The relevant portion og the Server (i.e. Service) code is:
public OMElement getPoints(OMElement inElem) throws SQLException,
IOException {
// inElem.build();
final MessageContext outContext=new MessageContext();
final SOAPEnvelope env=theSOAPFactory.getDefaultEnvelope();
final OMNamespace ns=theSOAPFactory.createOMNamespace(namespace,
"getPointsResponse");
// we can now disreagard this inElem
final OMElement
flexMobilePointListElem=theSOAPFactory.createOMElement(
"getPointsResponse",ns);
final ResultSet points;
final OMNamespace
pointNS=theSOAPFactory.createOMNamespace(namespace, "FlexMobilePoint");
try {
points=getPointsFromDB();
if (points!=null) {
// final ResultSet filteredPoints =
writeEntryForNullValues(flexMobilePointListElem,
// points);
int i=0;
while (points.next()) {
final OMElement thisPoint =
buildFlexMobilepointFromSQL(points,pointNS);
//
thisPoint.addAttribute(soapFac.createOMAttribute("position", omNs, new
Long(i).toString()));
i++;
flexMobilePointListElem.addChild(thisPoint);
}
}
flexMobilePointListElem.build();
env.getBody().addChild(flexMobilePointListElem);
outContext.setEnvelope(env);
return env;
// return toAxisElement(wrapInSoapMSG(flexMobilePointListElem));
// return flexMobilePointListElem;
} catch (final ClassNotFoundException e) {
throw new SQLException("Unable to instatiate the SQL
backend: ",e);
// } catch (final SOAPException soapExc) {
// throw new RuntimeException("There was a
SOAPException:",soapExc);
// } catch (final XMLStreamException e) {
// throw new RuntimeException("There was a
XMLStreamException:",e);
// } catch (final ParserConfigurationException e) {
// throw new RuntimeException("There was a
ParseConfigurationException",e);
}
// catch (final FactoryConfigurationError e) {
// throw new RuntimeException("There was a
FactoryConfigurationException",e);
// }
catch (final OMException e) {
throw new RuntimeException("There was a unspecified
Exception",e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: AXIS2 1.4: Client problems when changing form plain XML to SOAP-style
messages: Disallowed element found in envelope:Envelope..
Posted by Sanka Samaranayake <ss...@gmail.com>.
Hi Robert,
If I understand your problem correctly, all you need is to retrieve the
MobilePointList element via a SOAP from your back-end service. You can
follow Axis2 user guide sample when creating you own service. Just like
in sayHello(..) method, all you have to return is MobilePolicyList
element instead of returning it in a enclosed SOAP envelope. You don't
have to create the response envelope or set it in out message context.
You should be able to access the MobilePointList element as result
element in your client code.
i.e.
mepClient.execute(true); // This is line 73
final MessageContext response =
mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
final SOAPBody body = response.getEnvelope().getBody();
final OMElement result=body.getFirstElement();
HTH
Sanka
[1]
http://ws.apache.org/axis2/1_4/userguide-buildingservices.html#createscratch
Robert Ribnitz wrote:
> Hello Sanjiva,
>
> my basic porblem is the general lack of documentation; in the
> examples, there is a "SOAP with Attachments" example, but there is no
> example on how to use a plain SOAP message.
>
> I do have my list of Points (elements from the DB), which i need to
> return
>
> My interpretation of the doc was that this was the way to do it.
>
> I (and probably several others) would probably be grateful for an
> example of how to do plain SOAP (without attachments).
>
> On a side note: If I use ServiceClient (I don't really need
> OperationClient for this simple case, do I?) I get a very similar
> problem.
>
> On line 555 of ServiceClint (as of V 1.4) you do
>
> "return response.getEnvelope().getBody().getFirstElement();"
> which will of course fail for null envvelopes, or bodies?
>
> Can you give a very quick eample of how this should be done?
>
> Thank you
>
> Robert
>
> Sanjiva Weerawarana wrote:
>> The problem is that your service code is returning an entire SOAP
>> envelope. Is that what you wanted to do? Or did you mean to return
>> just a body? (It seems that you're not using outContext at all .. ?
>>
>> However, the bug is fishy .. I don't think the SOAP spec disallows
>> sending an entire SOAP envelope in the <Body>.
>>
>> Sanjiva.
>>
>> Robert Ribnitz wrote:
>>> Hello,
>>>
>>> I have also posted the following to the user list, with no response.
>>> As I think this might be an error in Axis2, I am forwarding this to
>>> the dev list.
>>>
>>> I have recently started to use AXIS2 (1.4) (on J2EE 5/with the Sun Java
>>> Application Server 9.1, using Java 6); the idea is to be able to create
>>> SOAP-based webservices to rsolve certain problems.
>>>
>>> Using plain AXIOM to generate client replies (these are generated based
>>> on Database input) is not too hard; client and server side work fine.
>>> However, as soon as i try to switch to SOAP basded Messaging, things go
>>> wrong; i get the exception as listed below
>>>
>>> This has probably been asked times and ties before.
>>>
>>> Can anyone tell me what I a doing wrong?
>>>
>>>
>>> Robert Ribnitz
>>>
>>>
>>> org.apache.axiom.soap.SOAPProcessingException: Disallowed element found
>>> inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Envelope
>>> at
>>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:298)
>>>
>>> at
>>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:212)
>>>
>>> at
>>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:191)
>>>
>>> at
>>> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
>>>
>>> at
>>> org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:633)
>>>
>>> at
>>> org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:141)
>>>
>>> at
>>> org.apache.axiom.om.impl.llom.OMElementImpl.getFirstElement(OMElementImpl.java:961)
>>>
>>> at
>>> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.java:84)
>>>
>>> at
>>> org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:74)
>>>
>>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:166)
>>> at
>>> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
>>>
>>> at
>>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
>>>
>>> at
>>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>>>
>>> at
>>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>>>
>>> at
>>> diuf.pai.flexmobile.dbwebservices.client.FlexMobilePointGetter.getPointsFromWebService(FlexMobilePointGetter.java:73)
>>>
>>> (more stacktrace)
>>>
>>>
>>> The relevant client code is:
>>>
>>> private final static EndpointReference EPR=new EndpointReference(
>>> //
>>> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
>>>
>>> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
>>> );
>>> @SuppressWarnings("unchecked")
>>> protected void getPointsFromWebService() {
>>> try {
>>> final ConfigurationContext
>>> ctx=ConfigurationContextFactory.createDefaultConfigurationContext();
>>> final ServiceClient theClient=new ServiceClient(ctx,null);
>>> final Options opts=new Options();
>>> opts.setAction("urn:getPoints");
>>> opts.setTo(EPR);
>>> opts.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>>> opts.setProperty(Constants.Configuration.ENABLE_REST,
>>> Constants.VALUE_FALSE);
>>>
>>> theClient.setOptions(opts);
>>>
>>> final OperationClient mepClient =
>>> theClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>>>
>>> final MessageContext mc = new MessageContext();
>>> final SOAPFactory sf=OMAbstractFactory.getSOAP11Factory();
>>> final OMNamespace
>>> ns=sf.createOMNamespace("http://dbwebservices.flexmobile.pai.diva/xsd",
>>> "PointReq");
>>> final OMElement
>>> elem=sf.createOMElement("getPointsRequest",ns);
>>> final SOAPEnvelope env=sf.getDefaultEnvelope();
>>> env.getBody().addChild(elem);
>>> mc.setEnvelope(env);
>>> mepClient.addMessageContext(mc);
>>> mepClient.execute(true); // This is line 73
>>> final MessageContext response =
>>> mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>>> final SOAPBody body = response.getEnvelope().getBody();
>>> final OMElement result=body.getFirstElement();
>>> // final OMElement result=theClient.sendReceive(elem);
>>> thePointList.clear();
>>> final Iterator<OMElement>
>>> resultChildrenIterator=result.getChildrenWithLocalName("getPointsResponse");
>>>
>>> // filling in the thePointList using the iteator
>>> // now everything is in a List,
>>> } catch (final AxisFault e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> } catch (final Exception e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>>
>>> The relevant portion og the Server (i.e. Service) code is:
>>>
>>> public OMElement getPoints(OMElement inElem) throws SQLException,
>>> IOException {
>>> // inElem.build();
>>> final MessageContext outContext=new MessageContext();
>>> final SOAPEnvelope env=theSOAPFactory.getDefaultEnvelope();
>>> final OMNamespace ns=theSOAPFactory.createOMNamespace(namespace,
>>> "getPointsResponse");
>>> // we can now disreagard this inElem
>>> final OMElement
>>> flexMobilePointListElem=theSOAPFactory.createOMElement(
>>> "getPointsResponse",ns);
>>> final ResultSet points;
>>> final OMNamespace
>>> pointNS=theSOAPFactory.createOMNamespace(namespace, "FlexMobilePoint");
>>>
>>> try {
>>> points=getPointsFromDB();
>>>
>>> if (points!=null) {
>>> // final ResultSet filteredPoints =
>>> writeEntryForNullValues(flexMobilePointListElem,
>>> // points);
>>> int i=0;
>>> while (points.next()) {
>>> final OMElement thisPoint =
>>> buildFlexMobilepointFromSQL(points,pointNS);
>>> //
>>> thisPoint.addAttribute(soapFac.createOMAttribute("position", omNs, new
>>> Long(i).toString()));
>>> i++;
>>>
>>> flexMobilePointListElem.addChild(thisPoint);
>>> }
>>>
>>> }
>>> flexMobilePointListElem.build();
>>> env.getBody().addChild(flexMobilePointListElem);
>>> outContext.setEnvelope(env);
>>> return env;
>>> // return
>>> toAxisElement(wrapInSoapMSG(flexMobilePointListElem));
>>> // return flexMobilePointListElem;
>>> } catch (final ClassNotFoundException e) {
>>> throw new SQLException("Unable to instatiate the SQL
>>> backend: ",e);
>>> // } catch (final SOAPException soapExc) {
>>> // throw new RuntimeException("There was a
>>> SOAPException:",soapExc);
>>> // } catch (final XMLStreamException e) {
>>> // throw new RuntimeException("There was a
>>> XMLStreamException:",e);
>>> // } catch (final ParserConfigurationException e) {
>>> // throw new RuntimeException("There was a
>>> ParseConfigurationException",e);
>>> }
>>> // catch (final FactoryConfigurationError e) {
>>> // throw new RuntimeException("There was a
>>> FactoryConfigurationException",e);
>>> // }
>>> catch (final OMException e) {
>>> throw new RuntimeException("There was a unspecified
>>> Exception",e);
>>> }
>>> }
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>
>
--
Sanka Samaranayake
WSO2 Inc.
http://sankas.blogspot.com/
http://www.wso2.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: AXIS2 1.4: Client problems when changing form plain XML to SOAP-style
messages: Disallowed element found in envelope:Envelope..
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Robert Ribnitz wrote:
> Hello Sanjiva,
>
> my basic porblem is the general lack of documentation; in the
> examples, there is a "SOAP with Attachments" example, but there is no
> example on how to use a plain SOAP message.
What about the echo sample? If you already have the SOAP envelope, all
you have to do is to extract the body and return.
Samisa...
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: AXIS2 1.4: Client problems when changing form plain XML to SOAP-style
messages: Disallowed element found in envelope:Envelope..
Posted by Robert Ribnitz <ro...@unifr.ch>.
Hello Sanjiva,
my basic porblem is the general lack of documentation; in the examples,
there is a "SOAP with Attachments" example, but there is no example on
how to use a plain SOAP message.
I do have my list of Points (elements from the DB), which i need to return
My interpretation of the doc was that this was the way to do it.
I (and probably several others) would probably be grateful for an
example of how to do plain SOAP (without attachments).
On a side note: If I use ServiceClient (I don't really need
OperationClient for this simple case, do I?) I get a very similar problem.
On line 555 of ServiceClint (as of V 1.4) you do
"return response.getEnvelope().getBody().getFirstElement();"
which will of course fail for null envvelopes, or bodies?
Can you give a very quick eample of how this should be done?
Thank you
Robert
Sanjiva Weerawarana wrote:
> The problem is that your service code is returning an entire SOAP
> envelope. Is that what you wanted to do? Or did you mean to return
> just a body? (It seems that you're not using outContext at all .. ?
>
> However, the bug is fishy .. I don't think the SOAP spec disallows
> sending an entire SOAP envelope in the <Body>.
>
> Sanjiva.
>
> Robert Ribnitz wrote:
>> Hello,
>>
>> I have also posted the following to the user list, with no response.
>> As I think this might be an error in Axis2, I am forwarding this to
>> the dev list.
>>
>> I have recently started to use AXIS2 (1.4) (on J2EE 5/with the Sun Java
>> Application Server 9.1, using Java 6); the idea is to be able to create
>> SOAP-based webservices to rsolve certain problems.
>>
>> Using plain AXIOM to generate client replies (these are generated based
>> on Database input) is not too hard; client and server side work fine.
>> However, as soon as i try to switch to SOAP basded Messaging, things go
>> wrong; i get the exception as listed below
>>
>> This has probably been asked times and ties before.
>>
>> Can anyone tell me what I a doing wrong?
>>
>>
>> Robert Ribnitz
>>
>>
>> org.apache.axiom.soap.SOAPProcessingException: Disallowed element found
>> inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Envelope
>> at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:298)
>>
>> at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:212)
>>
>> at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:191)
>>
>> at
>> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
>>
>> at
>> org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:633)
>>
>> at
>> org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:141)
>>
>> at
>> org.apache.axiom.om.impl.llom.OMElementImpl.getFirstElement(OMElementImpl.java:961)
>>
>> at
>> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.java:84)
>>
>> at
>> org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:74)
>>
>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:166)
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
>>
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
>>
>> at
>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>>
>> at
>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>>
>> at
>> diuf.pai.flexmobile.dbwebservices.client.FlexMobilePointGetter.getPointsFromWebService(FlexMobilePointGetter.java:73)
>>
>> (more stacktrace)
>>
>>
>> The relevant client code is:
>>
>> private final static EndpointReference EPR=new EndpointReference(
>> //
>> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
>>
>> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
>> );
>> @SuppressWarnings("unchecked")
>> protected void getPointsFromWebService() {
>> try {
>> final ConfigurationContext
>> ctx=ConfigurationContextFactory.createDefaultConfigurationContext();
>> final ServiceClient theClient=new ServiceClient(ctx,null);
>> final Options opts=new Options();
>> opts.setAction("urn:getPoints");
>> opts.setTo(EPR);
>> opts.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>> opts.setProperty(Constants.Configuration.ENABLE_REST,
>> Constants.VALUE_FALSE);
>>
>> theClient.setOptions(opts);
>>
>> final OperationClient mepClient =
>> theClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>>
>> final MessageContext mc = new MessageContext();
>> final SOAPFactory sf=OMAbstractFactory.getSOAP11Factory();
>> final OMNamespace
>> ns=sf.createOMNamespace("http://dbwebservices.flexmobile.pai.diva/xsd",
>> "PointReq");
>> final OMElement
>> elem=sf.createOMElement("getPointsRequest",ns);
>> final SOAPEnvelope env=sf.getDefaultEnvelope();
>> env.getBody().addChild(elem);
>> mc.setEnvelope(env);
>> mepClient.addMessageContext(mc);
>> mepClient.execute(true); // This is line 73
>> final MessageContext response =
>> mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
>> final SOAPBody body = response.getEnvelope().getBody();
>> final OMElement result=body.getFirstElement();
>> // final OMElement result=theClient.sendReceive(elem);
>> thePointList.clear();
>> final Iterator<OMElement>
>> resultChildrenIterator=result.getChildrenWithLocalName("getPointsResponse");
>>
>> // filling in the thePointList using the iteator
>> // now everything is in a List,
>> } catch (final AxisFault e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> } catch (final Exception e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>> }
>>
>>
>> The relevant portion og the Server (i.e. Service) code is:
>>
>> public OMElement getPoints(OMElement inElem) throws SQLException,
>> IOException {
>> // inElem.build();
>> final MessageContext outContext=new MessageContext();
>> final SOAPEnvelope env=theSOAPFactory.getDefaultEnvelope();
>> final OMNamespace ns=theSOAPFactory.createOMNamespace(namespace,
>> "getPointsResponse");
>> // we can now disreagard this inElem
>> final OMElement
>> flexMobilePointListElem=theSOAPFactory.createOMElement(
>> "getPointsResponse",ns);
>> final ResultSet points;
>> final OMNamespace
>> pointNS=theSOAPFactory.createOMNamespace(namespace, "FlexMobilePoint");
>>
>> try {
>> points=getPointsFromDB();
>>
>> if (points!=null) {
>> // final ResultSet filteredPoints =
>> writeEntryForNullValues(flexMobilePointListElem,
>> // points);
>> int i=0;
>> while (points.next()) {
>> final OMElement thisPoint =
>> buildFlexMobilepointFromSQL(points,pointNS);
>> //
>> thisPoint.addAttribute(soapFac.createOMAttribute("position", omNs, new
>> Long(i).toString()));
>> i++;
>>
>> flexMobilePointListElem.addChild(thisPoint);
>> }
>>
>> }
>> flexMobilePointListElem.build();
>> env.getBody().addChild(flexMobilePointListElem);
>> outContext.setEnvelope(env);
>> return env;
>> // return toAxisElement(wrapInSoapMSG(flexMobilePointListElem));
>> // return flexMobilePointListElem;
>> } catch (final ClassNotFoundException e) {
>> throw new SQLException("Unable to instatiate the SQL
>> backend: ",e);
>> // } catch (final SOAPException soapExc) {
>> // throw new RuntimeException("There was a
>> SOAPException:",soapExc);
>> // } catch (final XMLStreamException e) {
>> // throw new RuntimeException("There was a
>> XMLStreamException:",e);
>> // } catch (final ParserConfigurationException e) {
>> // throw new RuntimeException("There was a
>> ParseConfigurationException",e);
>> }
>> // catch (final FactoryConfigurationError e) {
>> // throw new RuntimeException("There was a
>> FactoryConfigurationException",e);
>> // }
>> catch (final OMException e) {
>> throw new RuntimeException("There was a unspecified
>> Exception",e);
>> }
>> }
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org
Re: AXIS2 1.4: Client problems when changing form plain XML to SOAP-style
messages: Disallowed element found in envelope:Envelope..
Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
The problem is that your service code is returning an entire SOAP
envelope. Is that what you wanted to do? Or did you mean to return just a
body? (It seems that you're not using outContext at all .. ?
However, the bug is fishy .. I don't think the SOAP spec disallows sending
an entire SOAP envelope in the <Body>.
Sanjiva.
Robert Ribnitz wrote:
> Hello,
>
> I have also posted the following to the user list, with no response. As
> I think this might be an error in Axis2, I am forwarding this to the dev
> list.
>
> I have recently started to use AXIS2 (1.4) (on J2EE 5/with the Sun Java
> Application Server 9.1, using Java 6); the idea is to be able to create
> SOAP-based webservices to rsolve certain problems.
>
> Using plain AXIOM to generate client replies (these are generated based
> on Database input) is not too hard; client and server side work fine.
> However, as soon as i try to switch to SOAP basded Messaging, things go
> wrong; i get the exception as listed below
>
> This has probably been asked times and ties before.
>
> Can anyone tell me what I a doing wrong?
>
>
> Robert Ribnitz
>
>
> org.apache.axiom.soap.SOAPProcessingException: Disallowed element found
> inside Envelope : {http://www.w3.org/2003/05/soap-envelope}Envelope
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:298)
>
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:212)
>
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:191)
>
> at
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
> at
> org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:633)
>
> at
> org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:141)
>
> at
> org.apache.axiom.om.impl.llom.OMElementImpl.getFirstElement(OMElementImpl.java:961)
>
> at
> org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.getHeader(SOAPEnvelopeImpl.java:84)
>
> at
> org.apache.axis2.engine.AxisEngine.checkMustUnderstand(AxisEngine.java:74)
> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:166)
> at
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:363)
>
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
>
> at
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>
> at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
> at
> diuf.pai.flexmobile.dbwebservices.client.FlexMobilePointGetter.getPointsFromWebService(FlexMobilePointGetter.java:73)
>
> (more stacktrace)
>
>
> The relevant client code is:
>
> private final static EndpointReference EPR=new EndpointReference(
> //
> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
>
> "http://localhost:8080/axis2/services/FlexMobilePointGetterService"
> );
> @SuppressWarnings("unchecked")
> protected void getPointsFromWebService() {
> try {
> final ConfigurationContext
> ctx=ConfigurationContextFactory.createDefaultConfigurationContext();
> final ServiceClient theClient=new ServiceClient(ctx,null);
> final Options opts=new Options();
> opts.setAction("urn:getPoints");
> opts.setTo(EPR);
> opts.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> opts.setProperty(Constants.Configuration.ENABLE_REST,
> Constants.VALUE_FALSE);
>
> theClient.setOptions(opts);
>
> final OperationClient mepClient =
> theClient.createClient(ServiceClient.ANON_OUT_IN_OP);
>
> final MessageContext mc = new MessageContext();
> final SOAPFactory sf=OMAbstractFactory.getSOAP11Factory();
> final OMNamespace
> ns=sf.createOMNamespace("http://dbwebservices.flexmobile.pai.diva/xsd",
> "PointReq");
> final OMElement elem=sf.createOMElement("getPointsRequest",ns);
> final SOAPEnvelope env=sf.getDefaultEnvelope();
> env.getBody().addChild(elem);
> mc.setEnvelope(env);
> mepClient.addMessageContext(mc);
> mepClient.execute(true); // This is line 73
> final MessageContext response =
> mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
> final SOAPBody body = response.getEnvelope().getBody();
> final OMElement result=body.getFirstElement();
> // final OMElement result=theClient.sendReceive(elem);
> thePointList.clear();
> final Iterator<OMElement>
> resultChildrenIterator=result.getChildrenWithLocalName("getPointsResponse");
>
> // filling in the thePointList using the iteator
> // now everything is in a List,
> } catch (final AxisFault e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (final Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
>
>
> The relevant portion og the Server (i.e. Service) code is:
>
> public OMElement getPoints(OMElement inElem) throws SQLException,
> IOException {
> // inElem.build();
> final MessageContext outContext=new MessageContext();
> final SOAPEnvelope env=theSOAPFactory.getDefaultEnvelope();
> final OMNamespace ns=theSOAPFactory.createOMNamespace(namespace,
> "getPointsResponse");
> // we can now disreagard this inElem
> final OMElement
> flexMobilePointListElem=theSOAPFactory.createOMElement(
> "getPointsResponse",ns);
> final ResultSet points;
> final OMNamespace
> pointNS=theSOAPFactory.createOMNamespace(namespace, "FlexMobilePoint");
>
> try {
> points=getPointsFromDB();
>
> if (points!=null) {
> // final ResultSet filteredPoints =
> writeEntryForNullValues(flexMobilePointListElem,
> // points);
> int i=0;
> while (points.next()) {
> final OMElement thisPoint =
> buildFlexMobilepointFromSQL(points,pointNS);
> //
> thisPoint.addAttribute(soapFac.createOMAttribute("position", omNs, new
> Long(i).toString()));
> i++;
>
> flexMobilePointListElem.addChild(thisPoint);
> }
>
> }
> flexMobilePointListElem.build();
> env.getBody().addChild(flexMobilePointListElem);
> outContext.setEnvelope(env);
> return env;
> // return toAxisElement(wrapInSoapMSG(flexMobilePointListElem));
> // return flexMobilePointListElem;
> } catch (final ClassNotFoundException e) {
> throw new SQLException("Unable to instatiate the SQL
> backend: ",e);
> // } catch (final SOAPException soapExc) {
> // throw new RuntimeException("There was a
> SOAPException:",soapExc);
> // } catch (final XMLStreamException e) {
> // throw new RuntimeException("There was a
> XMLStreamException:",e);
> // } catch (final ParserConfigurationException e) {
> // throw new RuntimeException("There was a
> ParseConfigurationException",e);
> }
> // catch (final FactoryConfigurationError e) {
> // throw new RuntimeException("There was a
> FactoryConfigurationException",e);
> // }
> catch (final OMException e) {
> throw new RuntimeException("There was a unspecified
> Exception",e);
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>
--
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org