xml-namespacesworkday-apistrong-soap

Using Strong-soap node module, It is not adding namespace to the attributes of the elements


Using Strong-soap node module, It is not adding namespace to the attributes of the elements and due to which I am getting error -Invalid Attribute.

<ns1:Put_Applicant_Request xmlns:ns1="urn:com.workday/bsvc" version="v23.0">
  <ns1:Applicant_Data>
    <ns1:Personal_Data>
      <ns1:Name_Data>
        <ns1:Legal_Name_Data>
          <ns1:Name_Detail_Data>
            <ns1:Country_Reference Descriptor="?">
              <ns1:ID ns1:type="ISO_3166-1_Alpha-3_Code">USA</ns1:ID>
            </ns1:Country_Reference>
            <ns1:First_Name>Lionel</ns1:First_Name>
            <ns1:Last_Name>Messi</ns1:Last_Name>
          </ns1:Name_Detail_Data>
        </ns1:Legal_Name_Data>
      </ns1:Name_Data>
      <ns1:Contact_Data>
        <ns1:Email_Address_Data>
          <ns1:Email_Address>lmessi@email.net</ns1:Email_Address>
          <ns1:Usage_Data ns1:Public="false">
            <ns1:Type_Data ns1:Primary="true">
              <ns1:Type_Reference ns1:Descriptor="?">
                <ns1:ID ns1:type="Communication_Usage_Type_ID">HOME</ns1:ID>
              </ns1:Type_Reference>
            </ns1:Type_Data>
          </ns1:Usage_Data>
        </ns1:Email_Address_Data>
      </ns1:Contact_Data>
    </ns1:Personal_Data>
    <ns1:Recruiting_Data>
      <ns1:Positions_Considered_for_Reference ns1:Descriptor="?">
        <ns1:ID ns1:type="Position_ID">P-00054</ns1:ID>
      </ns1:Positions_Considered_for_Reference>
    </ns1:Recruiting_Data>
  </ns1:Applicant_Data>
</ns1:Put_Applicant_Request>

Now, Using the xml2json utility, I converetd this to JSON which is as below:

  Body:   { Put_Applicant_Request:
  { '$attributes': { version: 'v23.0' },
    Applicant_Data:
     { Personal_Data:
        { Name_Data:
           { Legal_Name_Data:
              { Name_Detail_Data:
                 { Country_Reference:
                    { '$attributes': { "xmlns": "urn:com.workday/bsvc",Descriptor: '?' },
                      ID:
                       { '$attributes': { type: 'ISO_3166-1_Alpha-3_Code' },
                         '$value': 'USA' } },
                   First_Name: 'Lionel',
                   Last_Name: 'Messi' } } },
          Contact_Data:
           { Email_Address_Data:
              { Email_Address: 'lmessi@email.net',
                Usage_Data:
                 { '$attributes': { Public: 'false' },
                   Type_Data:
                    { '$attributes': { Primary: 'true' },
                      Type_Reference:
                       { '$attributes': { Descriptor: '?' },
                         ID:
                          { '$attributes': { type: 'Communication_Usage_Type_ID' },
                            '$value': 'HOME' } } } } } } },
       Recruiting_Data:
        { Positions_Considered_for_Reference:
           { '$attributes': { Descriptor: '?' },
             ID: { '$attributes': { type: 'Position_ID' }, '$value': 'P-00054' } } } } } } }

Passing this input to the node module, the payload that is generated is as below which is not having namespace for the attribute tag and hence getting the error:

  <soap:Body>
<ns1:Put_Applicant_Request xmlns:ns1="urn:com.workday/bsvc" version="v23.0">
  <ns1:Applicant_Data>
    <ns1:Personal_Data>
      <ns1:Name_Data>
        <ns1:Legal_Name_Data>
          <ns1:Name_Detail_Data>
            <ns1:Country_Reference xmlns="urn:com.workday/bsvc11" Descriptor="?">
              <ns1:ID type="ISO_3166-1_Alpha-3_Code">USA</ns1:ID>
            </ns1:Country_Reference>
            <ns1:First_Name>Lionel</ns1:First_Name>
            <ns1:Last_Name>Messi</ns1:Last_Name>
          </ns1:Name_Detail_Data>
        </ns1:Legal_Name_Data>
      </ns1:Name_Data>
      <ns1:Contact_Data>
        <ns1:Email_Address_Data>
          <ns1:Email_Address>lmessi@email.net</ns1:Email_Address>
          <ns1:Usage_Data Public="false">
            <ns1:Type_Data Primary="true">
              <ns1:Type_Reference Descriptor="?">
                <ns1:ID type="Communication_Usage_Type_ID">HOME</ns1:ID>
              </ns1:Type_Reference>
            </ns1:Type_Data>
          </ns1:Usage_Data>
        </ns1:Email_Address_Data>
      </ns1:Contact_Data>
    </ns1:Personal_Data>
    <ns1:Recruiting_Data>
      <ns1:Positions_Considered_for_Reference Descriptor="?">
        <ns1:ID type="Position_ID">P-00054</ns1:ID>
      </ns1:Positions_Considered_for_Reference>
    </ns1:Recruiting_Data>
  </ns1:Applicant_Data>
</ns1:Put_Applicant_Request>

I am getting below error:

     <SOAP-ENV:Fault xmlns:wd="urn:com.workday/bsvc">
     <faultcode>SOAP-ENV:Client.validationError</faultcode>
     <faultstring>Validation error occurred. Invalid Attribute Descriptor- for element Person_Name_Detail_Data (6$17160)</faultstring>
     <detail>
        <wd:Validation_Fault>
           <wd:Validation_Error>
              <wd:Message>Invalid Attribute Descriptor- for element Person_Name_Detail_Data (6$17160)</wd:Message>
              <wd:Detail_Message>Invalid Attribute Descriptor- for element Person_Name_Detail_Data (6$17160)</wd:Detail_Message>
              <wd:Xpath>/ns1:Put_Applicant_Request[1]/ns1:Applicant_Data[1]/ns1:Personal_Data[1]/ns1:Name_Data[1]/ns1:Legal_Name_Data[1]/ns1:Name_Detail_Data[1]/ns1:Country_Reference[1]/@Descriptor</wd:Xpath>
           </wd:Validation_Error>
        </wd:Validation_Fault>
     </detail>
  </SOAP-ENV:Fault>

Any pointers on how I could fix this issue?


Solution

  • I have raised a issue under the node module repository and this is now fixed by the repository owners. Refer issue - https://github.com/strongloop/strong-soap/issues/134 for more details on the fix.