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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to