2 Replies Latest reply on Feb 6, 2013 12:46 PM by 735835

    XML Response Message difficulty, Please help..

      I am working on a request as well as a response message and am having some difficulty on the response side of things. The general task is an inbound interface that consumes an XML file, and then send a message back to the source sytem with a confirmation or error. The consume part is working at this point. Here are the details on my response..

      Message xsd schema...
      <?xml version="1.0"?>
      <xs:schema targetNamespace="http://mdcourts.backoffice.jaxb" version="1.0" xmlns:tns="http://mdcourts.backoffice.jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="PaymentTransactionsMessage">
      <xs:element form="qualified" maxOccurs="unbounded" name="PaymentData" type="tns:PaymentDataType"/>
      <xs:element name="PaymentTransactionsResponseMessage" nillable="true">
      <xs:element form="qualified" name="ResponseMessage" type="tns:ResponseMessageType"/>
      <xs:complexType name="ResponseMessageType">
      <xs:element name="ReturnResult" type="xs:string"/>

      PeopleCode in my App Pack specific to response only...
      &response = CreateMessage(Operation.AOC_PYMNT_TRANS, %IntBroker_Response);
      &xmlrespdata = "<?xml version='1.0'?>";
      &xmldoc = CreateXmlDoc(&xmlrespdata);

      &rootnode = &xmldoc.DocumentElement.AddElement("ResponseMessage");
      &childnode = &rootnode.AddElement("ReturnResult");
      &textnode = &childnode.AddText(String(&County));

      Return &response

      I am using SOAPui to test this and am getting an 'Invalid Document Structure' on the response side.

      Here is the error returned in SOAP...
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <IBResponse type="error">
      <DefaultTitle>Integration Broker Response</DefaultTitle>
      <DefaultMessage>XML parser error CreateXmlDoc Fatal Error: at file Integration Server line: 1 column: 22 message: Invalid document structure (159,5) AOC_IB_APP_PACK.AOC_IB_PROCESSING.OnExecute Name:OnRequest PCPC:12415 Statement:210</DefaultMessage>
      <Parameter>Fatal Error: at file Integration Server line: 1 column: 22 message: Invalid document structure</Parameter>

      Thank you very much for the help.
        • 1. Re: XML Response Message difficulty, Please help..
          your code contains a few errors
          &xmlrespdata = "<?xml version='1.0'?>";
          &xmldoc = CreateXmlDoc(&xmlrespdata);
          add a root element to the createxmldoc
          &xmlrespdata = "<?xml version='1.0'?><ResponseMessage/>";
          &xmldoc = CreateXmlDoc(&xmlrespdata);
          or use CreateDocumentElement() to add a root after creating a empty xmldoc

          &rootnode = &xmldoc.DocumentElement.AddElement("ResponseMessage");
          judging by your name &rootnode I think you want to create root element, whereas &xmldoc.DocumentElement is already your root node. With &xmldoc.DocumentElement.AddElement("ResponseMessage"); you add a new element under the root node.

          Please have a look at a tutorial a posted on working with Integration Broker and how to handle webservices.
          • 2. Re: XML Response Message difficulty, Please help..

            In your schema you probably want to add form="qualified" to <xs:element name="ReturnResult" type="xs:string"/> to prevent it ending up with no namespace (it's difficult to add xmlns="" via peoplecode).

            &Country = "Spain";

            &soapRes = CreateSOAPDoc();
            &soapRes.BodyNode.AddElementNS("http://mdcourts.backoffice.jaxb", "PaymentTransactionsResponseMessage").AddElement("ResponseMessage").AddElement("ReturnResult").AddText(&Country);

            Return &response