Thanks, but I resolved the issue: see code below*

Craig Hickman, Sr. Architect ADP

Working with the previous Axis1 I was able to write a very easy
implementaion for a ServiceRouter and ServiceProcessor that worked for
exposing all my services through a properties lookup and hiding the Axis1
implementaion and complexity for users. Now I figure to do the same. Being a
java guy, I wondered why people needed to go through all these extra steps
to use code generators, even if they are nice and slick and supposedly are
there to help I have issues and concerns of maintainability and ease of use
of other developers in house who will be left to build on these services.
Not the way to go. So I figure its best to expose only what is worthwhile in
your api and create a set of utility classes that will help regular java
developers build the services easily without knowing all the goodies behind
the scenes.

I'm well on the way of doing this and simplifying things for others. I think
once I do this I'm defintely going to write a pro/con article on my
experience with the Axis2 api and third party tools which it uses. I like
Axis2 but think things could be improved greatly for users in the sense of
thinking in java and objects in a manner that is more user friendly.
Obviously this is just my own opinon and hopefully you will not take it as a
negative in a detrimental sense. 

After I finish this would it be worthwhile to send my findings to anyone
within the Axis2 community?


*
Test XML pull parsed:

            <service>
               <partner-num>100250</partner-num>
               <client-id>146</client-id>
               <auth-code>potato123</auth-code>
               <client-user>2</client-user>
               <client-id2>3</client-id2>
 
<browser-form-post>http://www.someplace.com</browser-form-post>
               <operation>create</operation>
               <client-id3>7</client-id3>
            </service>

The public method in the skeleton that is called by the receiver:

public org.apache.axiom.soap.SOAPEnvelope
create(org.apache.axis2.context.MessageContext msgContext) throws
ErrorException {
                
                
            envelope = msgContext.getEnvelope();
            try {
                        SOAPBody body = envelope.getBody();
                            if (body == null) {
                                ErrorException run =
utils.getErrorMessage(WSConstants.SOAP_MESSAGE_MISSING);
                                throw run;
                            }
                                // GET THE FIRST ELEMENT 
                                OMElement root =
utils.getOMRootElement(envelope);
                                        // SET THE PARTNER SERVICE OBJECTS
                                        QName serviceQN = new
QName(WSConstants.SERVICE);
                                        Iterator serviceIter =
root.getChildrenWithName(serviceQN); 
                                        getService(serviceIter); // the
private method that gets the elements and sets the bean 
                                        
                                        
                                        // SET THE CANDIDATE SERVICE OBJECTS
                                        QName candidateQN = new
QName(WSConstants.CANDIDATE);
                                        Iterator candidate =
root.getChildrenWithName(candidateQN);
                                        getCandidate(candidate);
 
                                        // UNLOAD THE SERVICE AND SEND THE
OBJECTS TO THE SASSCORE SERVICES
                                        service = new ServiceManagerImpl();
                                        envelope =
service.create(this.getSsoBO()); // delegate that sends all to backend
POJO's

                                        
                } catch (OMException e) {
                        ErrorException ex =
utils.getErrorMessage(WSConstants.SERVICE_FAILED);
                        throw ex;
                }
                
                return envelope;

        }

The private util method in the skel:

private void getService(Iterator serv) {
                Map aMap = new HashMap();
                
                //-- pass in iterator and constants for simple xml element
parsing --//
                try {
                        aMap = utils.getOMTextToMap(serv,
Arrays.asList(WSConstants.SERVICE_ARRAY)); // call to the
XMLUtils.getOMTextToMap(...)
                        int mapsize = aMap.size();

                        Iterator keyValuePairs1 =
aMap.entrySet().iterator();
                        for (int i = 0; i < mapsize; i++)
                        {
                          Map.Entry entry = (Map.Entry)
keyValuePairs1.next();
                          Object key = entry.getKey();
                          Object value = entry.getValue();
                          getServiceElementsSwitch(key, value);
                        }
                } catch (SOAPException e) {
                        logger.debug("getService SOAPException"
+e.getMessage());
                        e.printStackTrace();
                } catch (XMLStreamException e) {
                        logger.debug("getService XMLStreamException"
+e.getMessage());
                        e.printStackTrace();
                }
        }
 
The methods in my XMLUtils 
    
      //--- util method to return text in a map 
      public Map getOMTextToMap(Iterator iter, List<String> wsConstants)
throws SOAPException, XMLStreamException {
                int j = 1;
                String text = "";
                while (iter.hasNext()) {
                    Object o = iter.next();
                                for (int i = 0; i < wsConstants.size(); i++)
{ 
                                        String qName =
(String)wsConstants.get(i);
                                    if  (o instanceof OMElement) {
                                            OMElement c = (OMElement) o;
                                            OMElement element =
getOMElement(c, qName);
                                            text = element.getText();
                                            map.put(j, text);
                                           j++;
                                    }
                                }
                        }
                return map;     
        }

      //--- util method to get the text
        public  OMElement getOMElement(OMElement result, String element)
            throws SOAPException, XMLStreamException {

            QName qName = new QName(element);
            if (qName == null) {
              throw new RuntimeException("Missing required method
element.");
            }

            Iterator i = result.getChildrenWithName(qName); 
            if (! i.hasNext()) {
              throw new RuntimeException("Missing required  element.");
            }

            OMElement omElement = (OMElement) i.next();

            return omElement;
          }
        

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

Reply via email to