Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Stevie Mayhew
    "Header not understood" error message - PHP
    Topic posted April 22, 2012 by Stevie Mayhew 
    3335 Views, 5 Comments
    Title:
    "Header not understood" error message - PHP
    Content:

    Hiya,

    I'm writing a connection API to RightNow in PHP and having a total blast... :D

     

    I've run across an error that I don't understand and can't find any documentation on, or work out what is wrong with my request - Header Not Understood.

    This only happens when I include the ClientInfoHeader as part of the soap request, otherwise I get an error "Data element in the Message is NULL" which is probably due to something else being wrong.

    Any help as to what I'm doing wrong would be fantastic.

     

    Thanks,

    Stevie

    Code Snippet:

    Comment

     

    • Allan Schrum

      The field mustUnderstand is a SOAP convention which means, "Either I understand what this means, or I abort". Associating it with the ClientInfoHeader is not necessary even though the ClientInfoHeader is required. Usually, the mustUnderstand parameter is associated with the security header declaring the username and password for authentication. This implies, "Either I understand what this security header means and I can process it, or I abort".

      Here is a sample request that shows how all these pieces work.

      Regards,

      -Allan

      This is an example of a Batch request containing a couple of simple "Get" and QueryCSV requests. Look for YourUserNameHere and YourPasswordHere in the Security header.

          <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
              <soapenv:Header xmlns:rnm='urn:messages.ws.rightnow.com/v1_2'>
                  <rnm:ClientInfoHeader>
                      <rnm:AppID>Functional Test</rnm:AppID>
                  </rnm:ClientInfoHeader>
                  <wsse:Security soapenv:mustUnderstand='true' xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:wssu='http://docs.oasis-open.org/wss/2004/01/oasis-20040
      1-wss-wssecurity-utility-1.0.xsd'>
                      <wsse:UsernameToken>
                          <wsse:Username>YourUserNameHere</wsse:Username>
                          <wsse:Password wsse:Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>YourPasswordHere</wsse:Password>
                      </wsse:UsernameToken>
                  </wsse:Security>
              </soapenv:Header>
              <soapenv:Body>
                  <rnm:Batch
                              xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
                              xmlns:xs='http://www.w3.org/2001/XMLSchema'
                              xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                              xmlns:rnm='urn:messages.ws.rightnow.com/v1_2'
                              xmlns:rno='urn:objects.ws.rightnow.com/v1_2'
                              xmlns:rng='urn:generic.ws.rightnow.com/v1_2'
                              xmlns:rnb='urn:base.ws.rightnow.com/v1_2'
                              xmlns:rnok='urn:base.ws.rightnow.com/v1_2'>

      <rnm:BatchRequestItem><rnm:GetMsg>

      <rnm:RNObjects xsi:type='rno:Organization'>
          <rnok:ID id='31'/>
      </rnm:RNObjects>

      <rnm:RNObjects xsi:type='rno:Organization'>
          <rnok:ID id='31'/>
          <rno:FusionPartyReference />
      </rnm:RNObjects>

      <rnm:ProcessingOptions>
        <rnm:FetchAllNames>true</rnm:FetchAllNames>
      </rnm:ProcessingOptions>

      </rnm:GetMsg></rnm:BatchRequestItem>

      <!-- Validate through ROQL -->
      <rnm:BatchRequestItem>
        <rnm:QueryCSVMsg>
          <rnm:Query>
            SELECT * FROM Organization WHERE ID = 31
          </rnm:Query>
        </rnm:QueryCSVMsg>
      </rnm:BatchRequestItem>


                  </rnm:Batch>
              </soapenv:Body>
          </soapenv:Envelope>

       

    • Stevie Mayhew

      Hi Allan,

      Thankyou for that! I've got past the error happening within the header and now am trying to pull out some data from the system as a test. I am getting an error "Data element in the Message is NULL"

      Here is my XML:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:base.ws.rightnow.com/v1_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:objects.ws.rightnow.com/v1_2" xmlns:ns3="urn:messages.ws.rightnow.com/v1_2" xmlns:ns4="urn:messages.ws.rightnow.com/v1" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <SOAP-ENV:Header>
      <ns4:ClientInfoHeader xsi:type="ns3:ClientInfoHeader"><ns3:AppID>Testing: Getting Answer</ns3:AppID></ns4:ClientInfoHeader>
      <ns5:Security xsi:type="ns5:wsse" SOAP-ENV:mustUnderstand="1">
      <ns5:UsernameToken><ns5:Username>***</ns5:Username><ns5:Password>***</ns5:Password></ns5:UsernameToken>
      </ns5:Security>
      </SOAP-ENV:Header>
      <SOAP-ENV:Body>
      <ns3:Get>
      <ns3:RNObjects xsi:type="ns2:Answer">
      <ns1:ID id="1"/>
      <ns2:AccessLevels xsi:nil="true"/>
      <ns2:AdminLastAccessTime xsi:nil="true"/>
      <ns2:AssignedSibling xsi:nil="true"/>
      <ns2:Banner xsi:nil="true"/>
      <ns2:Categories xsi:nil="true"/>
      <ns2:Comment xsi:nil="true"/>
      <ns2:CommonAttachments xsi:nil="true"/>
      <ns2:CommonComment xsi:nil="true"/>
      <ns2:ExpiresDate xsi:nil="true"/>
      <ns2:FileAttachments xsi:nil="true"/>
      <ns2:Keywords xsi:nil="true"/>
      <ns2:LastAccessTime xsi:nil="true"/>
      <ns2:LastNotificationTime xsi:nil="true"/>
      <ns2:Links xsi:nil="true"/>
      <ns2:NextNotificationTime xsi:nil="true"/>
      <ns2:Notes xsi:nil="true"/>
      <ns2:OriginalReferenceNumber xsi:nil="true"/>
      <ns2:Products xsi:nil="true"/>
      <ns2:PublishOnDate xsi:nil="true"/>
      <ns2:Question xsi:nil="true"/>
      <ns2:SiblingAnswers xsi:nil="true"/>
      <ns2:Solution xsi:nil="true"/>
      <ns2:UpdatedByAccount xsi:nil="true"/>
      <ns2:URL xsi:nil="true"/>
      <ns2:ValidNullFields xsi:nil="true"/>
      </ns3:RNObjects>
      <ns3:ProcessingOptions><ns3:FetchAllNames/></ns3:ProcessingOptions>
      </ns3:Get>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
       
      
      Is there any way to get better errors/work out what they actually mean?
      
       
      
      Thanks!
      
    • Allan Schrum

      Generally, that means that the XML is not properly structured to the point that the request-specific deserializer cannot figure it out. I'll look to see if we can get better error messages.

      You do not need all the xsi:nil="true" fields. In general it should not pose a problem, but since you are having trouble if you can eliminate all those excess fields it would help. Just supply the Get request, the RNObjects entry and the ID field. See my example above for Organization using Get (in Batch it is GetMsg).

      It looks like your request is OK otherwise, but I have not run your request to see what the specific issue is.

      Regards,

      -Allan

    • Stevie Mayhew

      Hi Allan,

      Thanks again for that. I'm now stuck at the same point with this query. Can anyone please try this query and let me know whats wrong? The error is still "Data element in the Message is NULL".

      I changed from trying to get an "Answer" object to a general "Incident".

      Thanks again,

      Stevie

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:base.ws.rightnow.com/v1_2" xmlns:ns2="urn:objects.ws.rightnow.com/v1_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="urn:messages.ws.rightnow.com/v1_2" xmlns:ns4="urn:messages.ws.rightnow.com/v1" xmlns:ns5="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <SOAP-ENV:Header>
      <ns4:ClientInfoHeader xsi:type="ns3:ClientInfoHeader"><ns3:AppID>Testing: Getting Answer</ns3:AppID></ns4:ClientInfoHeader>
      <ns5:Security xsi:type="ns5:wsse" SOAP-ENV:mustUnderstand="1">
      <ns5:UsernameToken><ns5:Username>***</ns5:Username><ns5:Password>***</ns5:Password></ns5:UsernameToken>
      </ns5:Security>
      </SOAP-ENV:Header>
      <SOAP-ENV:Body>
      <ns3:Get>
      <ns3:RNObjects xsi:type="ns2:Incident">
      <ns1:ID id="1"/>
      </ns3:RNObjects>
      </ns3:Get></SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
    • Allan Schrum

      The namespace you use for your ClientInfoHeader is incorrect. That object is, as your xsi:type says, an object (ns3) namespace object. You have ns4 bound to messages and ClientInfoHeader is not part of the message, it is information in the header. The corrected request (without security header) is:

      <SOAP-ENV:Envelope xmlns:ns4='urn:messages.ws.rightnow.com/v1' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns3='urn:messages.ws.rightnow.com/v1_2' xmlns:ns5='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='urn:base.ws.rightnow.com/v1_2' xmlns:ns2='urn:objects.ws.rightnow.com/v1_2'>
        <SOAP-ENV:Header>
          <ns3:ClientInfoHeader xsi:type='ns3:ClientInfoHeader'>
            <ns3:AppID>Testing: Getting Answer</ns3:AppID>
          </ns3:ClientInfoHeader>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
          <ns3:Get>
            <ns3:RNObjects xsi:type='ns2:Incident'>
              <ns1:ID id='1' />
            </ns3:RNObjects>
          </ns3:Get>
        </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Regards,

      -Allan