Tuesday, November 29, 2011

SAXParseException: The prefix for element is not bound

Problem

This is my request payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:acc="http://xml.ipnweb.com/Account/AccountSetup" xmlns:acc1="http://xml.ipnweb.com/Account" xmlns:root="http://xml.ipnweb.com/RootTypes">
  <soapenv:Header/>
  <soapenv:Body>
    <acc:AccountSetupTransaction>
      <acc:AccountSetupInformation>
        <acc:AccountInformation>
          <acc:AccountDetail>
            <acc1:AccountName>AHMED ABOULNAGA</acc1:AccountName>
            <acc1:AccountNumber>123456</acc1:AccountNumber>
          </acc:AccountDetail>
        </acc:AccountInformation>
      </acc:AccountSetupInformation>
    </acc:AccountSetupTransaction>
  </soapenv:Body>
</soapenv:Envelope>
This is my response payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:acc="http://xml.ipnweb.com/Account/AccountSetup" xmlns:acc1="http://xml.ipnweb.com/Account" xmlns:root="http://xml.ipnweb.com/RootTypes">
   <soapenv:Header/>
   <soapenv:Body>
      <AccountSetupTransaction xsi:schemaLocation="http://xml.ipnweb.com/Account/AccountSetup/Account.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xml.ipnweb.com/Account/AccountSetup" xmlns:acct="http://xml.ipnweb.com/Account">
         <Errors>
            <root:Error>
               <root:ErrorLevel>300</root:ErrorLevel>
               <root:ErrorCode>NB19805</root:ErrorCode>
               <root:ErrorMessageText>org.xml.sax.SAXParseException: The prefix "acc" for element "acc:AccountSetupTransaction" is not bound.</root:ErrorMessageText>
            </root:Error>
         </Errors>
      </AccountSetupTransaction>
   </soapenv:Body>
</soapenv:Envelope>

Solution

1. Remove all prefixes from source payload:

-OR-

2. Make the following change in the source payload:

OLD:
<acc:AccountSetupTransaction>

NEW:
<acc:AccountSetupTransaction xmlns:acc="http://xml.ipnweb.com/Account/AccountSetup" xmlns:acc1="http://xml.ipnweb.com/Account" xmlns:root="http://xml.ipnweb.com/RootTypes">

Ahmed Aboulnaga

No comments: