Re: Help with SOAP Message Routing !!!

Scott Nichol <[email protected]>
Newsgroups gmane.text.xml.soap.devel
Message-ID <3EAD5F58.7316.1ACD2C0@localhost>
If you are expecting each piece of info to be in its own element, you 
cannot use getAttribute in your code.  You need to be grabbing child 
nodes.

On 28 Apr 2003 at 21:30, Michael Fasosin wrote:

> Hi Scott,
> 
> Sorry I changed the references in the log and code to anything recognizable
> before I sent it hence that is why you saw InvoiceRoom. True is finds the
> elements but doesn't seem to be picking up the attributes which are dumped
> in the log. No, I'm expecting each to be in its own enclosed tag
> <WebURL>
> <urlName>GillsWebsite</urlName>
> <URL>http://www.gills.com</URL>
> </WebURL>
> 
> Like this,
> 
> Thanks for your help
> 
> Michael
> 
> ----- Original Message -----
> From: "Scott Nichol" <[email protected]>
> To: <[email protected]>
> Sent: Monday, April 28, 2003 7:29 PM
> Subject: Re: Help with SOAP Message Routing !!!
> 
> 
> >
> > A couple of things.
> >
> > 1. The code does not seems to exactly correspond to the log.
> > Specifically, the log talks about looking at BexQueryRoom, while the
> > code has the string InvoiceRoom.
> >
> > 2. The code finds elements such as WebURL, then reads attributes
> > thereof.  The XML dumped in your log shows no attributes.  Everything
> > is in child elements.  Are you really expecting attributes, e.g.
> >
> > <WebURL urlName="GillsWebsite" URL="http://www.gills.com" />
> >
> > On 28 Apr 2003 at 16:58, Michael Fasosin wrote:
> >
> > > Hi Scot,
> > >
> > > Thanks for your email,
> > >
> > > This is the content of my QMSWriter Below
> > >
> > >
> > > and logger it all goes to the log file. You'll notice that where the
> logger
> > > says Showing the Content of Discussion and InvoiceFolder below it is
> blank
> > > the funny thing is it actually goes into the If null logic before it
> > > executes that. I'm not sure what to do next.
> > >
> > > Thanks for replying.
> > >
> > > Regards
> > >
> > > Michael
> > >
> > >
> > > 2133 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > User Authorized
> > > 2133 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <Received a Create QueryRoom Request>
> > > 2133 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <We Need to Traverse the HTTP Headers and Show Them on the Screen>
> > > 2133 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <----------------------->
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <Checking the ReferenceDocuments Tag>
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <Checking the BexQueryRoom Tag>
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > Showing The Content of InvoiceFolder
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > Showing The Content of Discussion
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <Checking the WebURL Tag>
> > > 2143 [Thread-27] DEBUG
> om.intraspect.servlet.InvoiceIntegrationService  -
> > > <MessageHeader SOAP-ENV:mustUnderstand="1"
> > >
> xmlns:SOAP-ENV="urn:bex-qms-integration"><From>SOAPClientService</From><To>I
> > >
> nvoiceIntegrationService</To><MessageID>9999</MessageID></MessageHeader><Rec
> > > eiveEnvelopeWithAttachments xmlns="urn:bex-qms-integration">
> > >  <BexQueryRoom>
> > >   <invoiceNumber>34568</invoiceNumber>
> > >   <invoiceDate>02-Aug-2002</invoiceDate>
> > >   <invoiceValue>2300</invoiceValue>
> > >   <invoiceCurrency>GBP</invoiceCurrency>
> > >   <poNumber>24</poNumber>
> > >   <queryCreationDateTime>20-Feb-2003</queryCreationDateTime>
> > >   <invoiceCustomer>Philips</invoiceCustomer>
> > >   <tpID>2345</tpID>
> > >   <supplier>Viking</supplier>
> > >  </BexQueryRoom>
> > >  <ReferenceDocuments>
> > >   <fileName>InvoicePONumbers.xls</fileName>
> > >   <documentName>Intraspect Purchase Orders</documentName>
> > >   <attachment href="cid:the-attachment"/>
> > >  </ReferenceDocuments>
> > >  <WebURL>
> > >   <urlName>GillsWebsite</urlName>
> > >   <URL>http://www.gills.com</URL>
> > >  </WebURL>
> > > </ReceiveEnvelopeWithAttachments>
> > >
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Scott Nichol" <[email protected]>
> > > To: <[email protected]>
> > > Sent: Monday, April 28, 2003 4:27 PM
> > > Subject: Re: Help with SOAP Message Routing !!!
> > >
> > >
> > > > "Nothing seems to happen"?
> > > >
> > > > What gets written to QMSWriter?  What gets written to your logger?
> > > >
> > > > On 28 Apr 2003 at 8:17, Michael Fasosin wrote:
> > > >
> > > > > Hi All,
> > > > >
> > > > >
> > > > > I have a problem using SOAP2.3.1  Message Routing
> > > > >
> > > > > The Application I'm developing is essentially a SOAPService that
> will
> > > receive invoice/purchase order notifications with attachments etc. I've
> used
> > > > > the Apache Message Router to receive the message using the <method>
> > > <reqContext, reContext .....> signature.
> > > > >
> > > > > When I receive the message and I want to process it as indicated
> > > (essentially put the items in a vector) in the method below source.
> Nothing
> > > seems to happen. I don't know if I need to create a Document from the
> > > envelope or not. I've not found any reasonalble example that gives me an
> > > indication
> > > > as to what to do. I'll appreciate if you can spare a moment to look at
> the
> > > method below. The code executes all the logic but doesn't seem to
> populate
> > > my vector. The Writer however has data and writes to the log file.
> > > > >
> > > > > I'm using SOAP2.3 Libraries on Tomcat 4.0.1 javax.* transformer DOM
> > > libraries in the Apache Xerces 2.3 Libraries.
> > > > >
> > > > > I've pasted the relevant section of the code below.  I have a
> feeling it
> > > might have something to do with unmarshalling a document from the
> > > requestEnvelope not sure if I really need to do that for this so I'm
> asking
> > > for opinion from you folks.
> > > > >
> > > > > Thanks for your help
> > > > >
> > > > > Mike
> > > > >
> > > > >
> > > > >
> > > > >  public class InvoiceIntegrationService
> > > > >      extends HttpServlet
> > > > >      implements HttpMappingConstants {
> > > > >
> > > > > ........................................................
> > > > >
> > > > >    /**
> > > > >     *
> > > > >     * <br>
> > > > >     * This is the main method() that will be called when we get an
> > > incoming Request. This service will call
> > > > >         * others Services to do the rest of the work related to
> creating
> > > the  Room
> > > > >     * do the main work which is receiving the SOAP/XML Request from
> a
> > > Client and processing it.
> > > > >     * <br>
> > > > >     * Example:<br>
> > > > >     * <br>
> > > > >     *  http://fragma.com/soapserver/servlet/messagerouter<br>
> > > > >     * <br>
> > > > >     *
> > > > >     */
> > > > >    public void ReceiveEnvelopeWithAttachments(Envelope
> requestEnvelope,
> > > > >                                                  SOAPContext
> > > requestContext,
> > > > >                                                  SOAPContext
> > > responseContext) throws
> > > > >        IOException,
> > > > >        ServletException, SOAPException {
> > > > >      //Clear up anything we have from previous calls in Globals.
> > > > >      long startTime = new Date().getTime();
> > > > >
> > > > >      initElementsMappings();
> > > > >      HttpServletRequest request = (HttpServletRequest)
> > > > >
> requestContext.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
> > > > >      // Get the BASIC Authorization header from the Request
> > > > >      String authenticate = request.getHeader("Authorization");
> > > > >      // First Thing We'll do is Attempt to Authenticate The User.
> > > > >      logger.debug("Attempting to Authenticate The User" +
> authenticate);
> > > > >      if (!allowUser(authenticate)) {
> > > > >        // Not allowed, so report he's unauthorized
> > > > >        logger.debug("User Not Authorized");
> > > > >      }
> > > > >      else {
> > > > >        // We will place the rest of our code in here.
> > > > >        logger.debug("User Authorized");
> > > > >        try {
> > > > >          initElementsMappings();
> > > > >
> > > > >          logger.debug("<Received a Create Invoice Room Request>");
> > > > >          // We need to trasverse the Header to see what is in there.
> > > > >          // Traverse the HTTP headers and show them on the screen
> > > > >          logger.debug(
> > > > >              "<We Need to Traverse the HTTP Headers and Show Them on
> the
> > > Screen>");
> > > > >          Header header = requestEnvelope.getHeader();
> > > > >          Vector headerEntries = header.getHeaderEntries();
> > > > >
> > > > >          for (Enumeration enum = headerEntries.elements();
> > > enum.hasMoreElements(); ) {
> > > > >            Element el = (Element) enum.nextElement();
> > > > >            DOM2Writer.serializeAsXML( (Node) el, QMSWriter);
> > > > >          }
> > > > >          Body body = requestEnvelope.getBody();
> > > > >          Vector bodyEntries = body.getBodyEntries();
> > > > >          //We'll get the Top Level Body Entry Tag.
> > > > >
> > > > >          logger.debug("<----------------------->");
> > > > >          for (Enumeration e = bodyEntries.elements();
> > > e.hasMoreElements(); ) {
> > > > >            Element el = (Element) e.nextElement();
> > > > >            DOM2Writer.serializeAsXML( (Node) el, QMSWriter);
> > > > >
> > > > >            Element ReferenceDocuments = (Element)
> > > el.getElementsByTagName(
> > > > >                "ReferenceDocuments").item(0);
> > > > >            if (ReferenceDocuments != null) {
> > > > >              try {
> > > > >                // Loop through each ordered RoomDoc from the SOAP
> > > request
> > > > >                logger.debug("<Checking the ReferenceDocuments
> Tag>");
> > > > >                SOAPContext MimeSOAPContext = new SOAPContext();
> > > > >                // get the number of attachment count
> > > > >                int attachmentCount = MimeSOAPContext.getCount();
> > > > >                MimeBodyPart attachment;
> > > > >                // Get root part
> > > > >                MimeBodyPart rootPart =
> MimeSOAPContext.getRootPart();
> > > > >                // For every Attachment Received Get the BodyPart
> > > > >                for (int i = 0; i < MimeSOAPContext.getCount(); i++)
> {
> > > > >                  attachment = (MimeBodyPart)
> > > requestContext.getBodyPart(i);
> > > > >                  logger.debug(attachment);
> > > > >                  if (! (attachment.equals(rootPart))) {
> > > > >                    String qmsMimeType = attachment.getContentType();
> > > > >                    // Add the Documents Received into our CSPACE
> Vector
> > > Ready for use
> > > > >                    String fileName =
> > > ReferenceDocuments.getAttribute("fileName");
> > > > >                    String documentName =
> > > ReferenceDocuments.getAttribute(
> > > > >                        "documentName");
> > > > >                    cid =
> > > ReferenceDocuments.getAttribute("href").substring(4); // We want to get
> rid
> > > of the cid:.
> > > > >                    QMSWriter.write("Content-ID = "+cid+"\n");
> > > > >                    Object content = attachment.getContent();
> > > > >                    QMSWriter.write("The attachment
> > > is...\n"+attachment.getContent()+"\n");
> > > > >                    String classType = content.getClass().getName();
> > > > >                    if (attachment.isMimeType("text/*")) {
> > > > >                      logger.debug("<The mime data is in text
> format>");
> > > > >                    }
> > > > >                    else {
> > > > >                      logger.debug("<The mime data is in binary
> > > format>");
> > > > >                    }
> > > > >                    qmsItemsVect.addElement("fileName");
> > > > >                    qmsItemsVect.addElement("documentName");
> > > > >                    qmsItemsVect.addElement("qmsBodyPart");
> > > > >                    qmsItemsVect.addElement("qmsMimeType");
> > > > >                  }
> > > > >
> > > > >                }
> > > > >
> > > > >              }
> > > > >              catch (Exception DocItem) {
> > > > >                throw new SOAPException(HttpMappingConstants.
> > > > >
> INVOICEROOMCREATIONFAILDOCATTACH,
> > > > >                                        "Parsing Error Encountered",
> > > DocItem);
> > > > >              }
> > > > >            }
> > > > >            //Move the Room Items into something we can use.
> > > > >            // Ok Folks so We got this Item, We need to check that We
> > > have something in here.
> > > > >            Element InvoiceRoom = (Element) el.getElementsByTagName(
> > > > >                "InvoiceRoom").item(0);
> > > > >
> > > > >            if (InvoiceRoom != null) {
> > > > >
> > > > >              try {
> > > > >                // Loop through each ordered InvoiceRoom from the
> SOAP
> > > request
> > > > >                logger.debug("<Checking the InvoiceRoom Tag>");
> > > > >                String invoiceNumber = InvoiceRoom.getAttribute(
> > > > >                    "invoiceNumber");
> > > > >                String invoiceDate = InvoiceRoom.getAttribute(
> > > > >                    "invoiceDate");
> > > > >                String invoiceValue = InvoiceRoom.getAttribute(
> > > > >                    "invoiceValue");
> > > > >                String invoiceCurrency = InvoiceRoom.getAttribute(
> > > > >                    "invoiceCurrency");
> > > > >                String poNumber =
> InvoiceRoom.getAttribute("poNumber");
> > > > >                String queryCreationDateTime =
> InvoiceRoom.getAttribute(
> > > > >                    "queryCreationDateTime");
> > > > >                String invoiceCustomer = InvoiceRoom.getAttribute(
> > > > >                    "invoiceCustomer");
> > > > >                //    InvoiceFolder =
> > > InvoiceFolder.concat(HttpMappingConstants.INVOICEFOLDER);
> > > > >                //  InvoiceFolder =
> > > InvoiceFolder.concat(invoiceCustomer);
> > > > >                //   discussionAddress =
> > > discussionAddress.concat(invoiceCustomer);
> > > > >                //  discussionAddress =
> > > discussionAddress.concat(invoiceNumber);
> > > > >                logger.debug("Showing The Content of InvoiceFolder" +
> > > > >
> InvoiceRoom.getAttribute("invoiceNumber"));
> > > > >                logger.debug("Showing The Content of Discussion" +
> > > > >                             InvoiceCustomer);
> > > > >                String tpID = InvoiceRoom.getAttribute("tpID");
> > > > >                String supplier =
> InvoiceRoom.getAttribute("supplier");
> > > > >
> > > > >                // Add the Items Received into our Vector Ready for
> use
> > > > >                qmsItemsVect.addElement("invoiceNumber");
> > > > >                qmsItemsVect.addElement("invoiceDate");
> > > > >                qmsItemsVect.addElement("invoiceValue");
> > > > >                qmsItemsVect.addElement("invoiceCurrency");
> > > > >                qmsItemsVect.addElement("poNumber");
> > > > >                qmsItemsVect.addElement("queryCreationDateTime");
> > > > >                qmsItemsVect.addElement("InvoiceCustomer");
> > > > >                qmsItemsVect.addElement("tpID");
> > > > >                qmsItemsVect.addElement("supplier");
> > > > >                //  qmsItemsVect.addElement("InvoiceFolder");
> > > > >                //  qmsItemsVect.addElement("discussionAddress");
> > > > >              }
> > > > >              catch (Exception RoomItem) {
> > > > >                throw new SOAPException(HttpMappingConstants.
> > > > >
> INVOICEROOMCREATIONFAILINVNUM,
> > > > >                                        "Parsing Error Encountered",
> > > > >                                        RoomItem);
> > > > >              }
> > > > >            }
> > > > >            //Move the WebURLs Items into something we can use.
> > > > >            Element WebURL = (Element) el.getElementsByTagName(
> > > > >                "WebURL").item(0);
> > > > >            if (WebURL != null) {
> > > > >              try {
> > > > >                logger.debug("<Checking the WebURL Tag>");
> > > > >               // Loop through each ordered WebURL from the SOAP
> request
> > > > >                String urlName = WebURL.getAttribute("urlName");
> > > > >                String urlLink = WebURL.getAttribute("URL");
> > > > >                // Add the WebURLs Received into our Vector Ready for
> use
> > > > >                qmsItemsVect.addElement("urlName");
> > > > >                qmsItemsVect.addElement("urlLink");
> > > > >              }
> > > > >              catch (Exception WebItem) {
> > > > >                throw new SOAPException(HttpMappingConstants.
> > > > >                                        INVOICEROOMCREATIONFAILED,
> > > > >                                        "Web URL Not Specified",
> > > WebItem);
> > > > >              }
> > > > >            }
> > > > >          }
> > > > >
> > > > >          logger.debug(QMSWriter.toString());
> > > > >
> > > > >          long stopTime = new Date().getTime() - startTime;
> > > > >          logger.debug("Time for Processing SOAP Request Operation: "
> +
> > > stopTime);
> > > > >
> > > > >          try {
> > > > >            // Send the envelope back to the client
> > > > >            env.marshall(QMSWriter, null);
> > > > >            responseContext.setRootPart(QMSWriter.toString(),
> > > > >                                        "text/xml");
> > > > >          }
> > > > >          catch (Exception e) {
> > > > >            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> > > > >                "Error Writing Response Message Back To Server", e);
> > > > >          }
> > > > >
> > > > >        }
> > > > >        catch (Exception e) {
> > > > >          throw new SOAPException(BexHttpMappingConstants.
> > > > >                                  INVOICEROOMCREATIONFAILED,
> > > > >                                  "Error Attempting to Create Invoice
> > > Room", e);
> > > > >        }
> > > > >      }
> > > > >
> > > > >    }
> > > >
> > > >
> > > > Scott Nichol
> > > >
> > > > Do not reply directly to this e-mail address,
> > > > as it is filtered to only receive e-mail from
> > > > specific mailing lists.
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> > Scott Nichol
> >
> > Do not reply directly to this e-mail address,
> > as it is filtered to only receive e-mail from
> > specific mailing lists.
> >
> >
> 
> 
> 


Scott Nichol

Do not reply directly to this e-mail address,
as it is filtered to only receive e-mail from
specific mailing lists.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.