Title: SOAP With Attachment Problem Using SOAP 2.3.1

 Hi All,

I've got a problem extracting attachments from an SWA request sent to my provider. When a single file is sent I can process the request ok. I'm having problems processing array of documents in the request. I've attached the content of the request  (I've had to remove the content part from the output as the request file I sent  was too  big ,  the original message was bounced back)  . The request and the log debug are attached.


Here is the bit of code that is doing the work. I'm convinced there is something not quite right in how I extract the array from the request here but to be honest I can't tell what it is. Has anyone got any ideas looking at it. To see what the problem might be ?.

I would really appreciate it.

 


 public void ReceiveQMSEnvelopeWithAttachments(Envelope requestEnvelope,
                                                SOAPContext requestContext,
                                                SOAPContext responseContext) throws
      IOException, MessagingException, InvalidInputException,
      InvalidServerDataException {




//done loads of other stuff here............................
//before the below is executed..................................


    if (CreateStatus == true) {
          // We need to trasverse the Header to see what is in there.
          // Traverse the HTTP headers and process the content
          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);

//done loads of other stuff here............................
//before the below is executed..................................


         if (CreateStatus == true) {
              NodeList ReferenceDocumentsNodes = el.getElementsByTagName(
                  "ReferenceDocuments");

              if (ReferenceDocumentsNodes != null) {
                try {
                  // Loop through each ordered QueryRoomDoc from the SOAP request
                  logger.debug(
                      "<Checking the ReferenceDocuments Tag>");

                  // get the number of attachment count
                  int j;

                  // get the number of attachment count
                  int totalReferenceDocuments = ReferenceDocumentsNodes.
                      getLength();

                  logger.debug(
                      "<Checking the number of items in the ReferenceDocuments Tag " + totalReferenceDocuments + ">");


                  for (j = 0; j < totalReferenceDocuments; j++) {
                    Node ReferenceDocumentsNode = ReferenceDocumentsNodes.item(
                        j);
                    NodeList ReferenceDocumentsList = ReferenceDocumentsNode.
                        getChildNodes();
                    int attachmentCount = requestContext.getCount();
                    logger.debug(
                    "<Processing Each Item We Found " + attachmentCount + ">");

                    // Get root part
                    MimeBodyPart rootPart = requestContext.getRootPart();

                    logger.debug("<We've got the Root Part>");

                    String qmsMimeType = null;
                    String fileName = null;
                    String documentName = null;
                    Object content = null;

                    int n = ReferenceDocumentsList.getLength();
                    logger.debug("<Now We'll process the remaining elements in the Tag>");
                    for (int i = 0; i < n; i++) {
                      Node attributeNode = ReferenceDocumentsList.item(i);
                      String attributeName = attributeNode.getNodeName();
                      String value = attributeNode.getNodeValue();
                      Element attachmentEl = (Element) el.getElementsByTagName(
                          "attachment").item(0);
                      if (attachmentEl != null) {
                        for (int m = 0;
                             m < attachmentEl.getAttributes().getLength();
                             m++) {
                          cid = attachmentEl.getAttribute("href").substring(4);
                          attachment = requestContext.getBodyPart(cid);
                          qmsMimeType = attachment.getContentType();
                          content = attachment.getContent();

                          logger.debug("MimeType is " +
                                       qmsMimeType);

                          //cid = attachment.getContentID();
                          QMSWriter.write("Content-ID = " +
                                          cid + "\n");
                          QMSWriter.write(
                              "The attachment is...\n" +
                              attachment.getContent() + "\n");
                          content.getClass()
                              .getName().equals("java.io.ByteArrayInputStream");

                        }

                        if (attachment.isMimeType("text/*")) {
                          logger.debug(
                              "<The mime data is in text format>");
                        }
                        else {
                          logger.debug(
                              "<The mime data is in binary format>");
                        }
                      }

                      if (attributeName.equalsIgnoreCase(
                          "fileName")) {
                        NodeList valueList = attributeNode.getChildNodes();
                        value = valueList.item(0).getNodeValue();
                        logger.debug("fileName =" + value);
                        fileName = value;
                      }

                      if (attributeName.equalsIgnoreCase(
                          "documentName")) {
                        NodeList valueList = attributeNode.getChildNodes();
                        value = valueList.item(0).getNodeValue();
                        logger.debug("documentName =" + value);
                        documentName = value;
                      }
                    }
                    //If we don't get a mandatory value, fileName, add this to our errormsg vector
                    if (fileName == null) {
                      qmsFieldNames.add("fileName");
                      qmsMessages.add(BexHttpMappingConstants.
                                      QUERYROOMCREATIONFAILFILENAME);
                      // We don't want to Create a Room if we have problems.
                      CreateStatus = false;
                    }

                    //Add the items into our Docs ArrayList, First Add it to our ReferenceDocuments Object
                    if (CreateStatus == true) {
                      ReferenceDocuments tempReferenceDocuments = new
                          ReferenceDocuments(fileName, documentName,
                                             qmsMimeType,
                                             content);
                      //construct the array to save the ReferenceDocuments into
                      arrReferenceDocuments.add(tempReferenceDocuments);
                    }
                  }
                }
                catch (Exception DocItem) {
                  if (DocItem != null) {
                    // We delayed throwing the exception for Invalid Data Passed until we checked all the Tags
                    // Saves, making multiple calls until it is fixed.
                    if (qmsFieldNames.size() != 0) {
                      throw new InvalidInputException( (String[]) qmsFieldNames.
                          toArray(new
                                  String[1]),
                          (String[]) qmsMessages.toArray(new
                          String[1]));
                    }

                  }
                }
              }

            }

            logger.debug(QMSWriter.toString());

          }


Regards
Michael Fasosin <<SOAP Attacments.txt>>   <<SOAP-log.txt>>

POST /bexqms/servlet/messagerouter HTTP/1.0

Content-Type: multipart/related; type="text/xml"; 
start="<E9E15ED5F5AA8D6613F50075DC3F2CF3>";   
boundary="----=_Part_0_3578191.1062407908997"

Accept: application/soap+xml, application/dime, multipart/related, text/*

User-Agent: Axis/1.1

Host: disputeresolution.burnsecs.com

Cache-Control: no-cache

Pragma: no-cache

SOAPAction: ""

Content-Length: 388820

Authorization: Basic bW1jbmFtZWU6bW1jbmFtZWU=





------=_Part_0_3578191.1062407908997

Content-Type: text/xml; charset=UTF-8

Content-Transfer-Encoding: binary

Content-Id: <E9E15ED5F5AA8D6613F50075DC3F2CF3>



<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:SOAP-ENV="SOAP-ENV">
 <soapenv:Header>
  <SOAP-ENV:From soapenv:mustUnderstand="0" 
xmlns:SOAP-ENV="BurnsToInstraspectSOAPClientService"/>
  <SOAP-ENV:To soapenv:mustUnderstand="0" xmlns:SOAP-ENV="BexIntegrationService"/>
  <SOAP-ENV:MessageID soapenv:mustUnderstand="0" xmlns:SOAP-ENV="9999"/>
 </soapenv:Header>
 <soapenv:Body><ReceiveQMSEnvelopeWithAttachments xmlns="urn:bex-qms-integration">
  <BexQueryRoom>
    <invoiceNumber>Ben22</invoiceNumber>
    <invoiceDate>01-Sep-2003</invoiceDate>
    <invoiceValue>1620.72</invoiceValue>
    <invoiceCurrency>GBP</invoiceCurrency>
    <poNumber>222061</poNumber>
    <queryCreationDateTime>01-Sep-2003</queryCreationDateTime>
    <bexCustomer>philips</bexCustomer>
    <tpID>43824</tpID>
    <supplier>Burns Test</supplier>
  </BexQueryRoom>
  <ReferenceDocuments>
    <fileName>Ben22</fileName>
    <documentName>Ben22</documentName>
    <attachment href="cid:attachment0"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>ORDERSP869041</fileName>
    <documentName>ORDERSP869041</documentName>
    <attachment href="cid:attachment1"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>222061</fileName>
    <documentName>222061</documentName>
    <attachment href="cid:attachment2"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>Ben1</fileName>
    <documentName>Ben1</documentName>
    <attachment href="cid:attachment3"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>Ben2</fileName>
    <documentName>Ben2</documentName>
    <attachment href="cid:attachment4"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>ben11</fileName>
    <documentName>ben11</documentName>
    <attachment href="cid:attachment5"/>
  </ReferenceDocuments>
</ReceiveQMSEnvelopeWithAttachments> </soapenv:Body>
</soapenv:Envelope>
0    [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Show the 
RequestContext Object >[Parts={[cid:<E9E15ED5F5AA8D6613F50075DC3F2CF3> type: text/xml; 
charset=UTF-8 enc: binary], [cid:<cid:attachment0> type: text/plain enc: binary], 
[cid:<cid:attachment1> type: text/plain enc: binary], [cid:<cid:attachment2> type: 
text/plain enc: binary], [cid:<cid:attachment3> type: text/plain enc: binary], 
[cid:<cid:attachment4> type: text/plain enc: binary], [cid:<cid:attachment5> type: 
text/plain enc: binary]}]
16   [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - Attempting to 
Authenticate The UserBasic bW1jbmFtZWU6bW1jbmFtZWU=
2469 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - This is the User 
adminman
2469 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - User Authorized
2469 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Received a Create 
QueryRoom Request>
2469 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <We Need to 
Traverse the HTTP Headers and Show Them on the Screen>
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - 
<----------------------->
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Checking the 
BexQueryRoom Tag>
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - invoiceNumber 
=Ben22
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - invoiceDate 
=01-Sep-2003
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - invoiceValue 
=1620.72
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - invoiceCurrency 
=GBP
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - poNumber =222061
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - 
queryCreationDateTime =01-Sep-2003
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - bexCustomer 
=philips
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - tpID =43824
2485 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - supplier =Burns 
Test
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - This is The Query 
Room Entries: 1620.72
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Checking the 
WebURL Tag>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Checking the 
ReferenceDocuments Tag>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Checking the 
number of items in the ReferenceDocuments Tag 6>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Processing Each 
Item We Found 7>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <We've got the 
Root Part>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <Now We'll process 
the remaining elements in the Tag>
5657 [TXN-27] DEBUG com.intraspect.servlet.BexIntegrationService  - <SOAP-ENV:From 
soapenv:mustUnderstand="0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENV="BurnsToInstraspectSOAPClientService"/><SOAP-ENV:To 
soapenv:mustUnderstand="0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENV="BexIntegrationService"/><SOAP-ENV:MessageID soapenv:mustUnderstand="0" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:SOAP-ENV="9999"/><ReceiveQMSEnvelopeWithAttachments 
xmlns="urn:bex-qms-integration">
  <BexQueryRoom>
    <invoiceNumber>Ben22</invoiceNumber>
    <invoiceDate>01-Sep-2003</invoiceDate>
    <invoiceValue>1620.72</invoiceValue>
    <invoiceCurrency>GBP</invoiceCurrency>
    <poNumber>222061</poNumber>
    <queryCreationDateTime>01-Sep-2003</queryCreationDateTime>
    <bexCustomer>philips</bexCustomer>
    <tpID>43824</tpID>
    <supplier>Burns Test</supplier>
  </BexQueryRoom>
  <ReferenceDocuments>
    <fileName>Ben22</fileName>
    <documentName>Ben22</documentName>
    <attachment href="cid:attachment0"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>ORDERSP869041</fileName>
    <documentName>ORDERSP869041</documentName>
    <attachment href="cid:attachment1"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>222061</fileName>
    <documentName>222061</documentName>
    <attachment href="cid:attachment2"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>Ben1</fileName>
    <documentName>Ben1</documentName>
    <attachment href="cid:attachment3"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>Ben2</fileName>
    <documentName>Ben2</documentName>
    <attachment href="cid:attachment4"/>
  </ReferenceDocuments>
  <ReferenceDocuments>
    <fileName>ben11</fileName>
    <documentName>ben11</documentName>
    <attachment href="cid:attachment5"/>
  </ReferenceDocuments>
</ReceiveQMSEnvelopeWithAttachments>

Reply via email to