0

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?

Bhavna
  • 29
  • 5
  • can you share the function exact you are using for xml2json conversion? – Hikmat Dec 31 '17 at 18:37
  • I am using the xml2Json utility available under same node module - Link to refer - https://github.com/strongloop/strong-soap/blob/master/example/xml2json.js. I am passing the XML required by the Workday endpoint in this utility file and getting the desired JSON in the output structure. Its only when that JSON is being passed to the Strong-soap node module, internally it is generating XML payload to pass to the SOAP request which is not in the expected format and its missing the namespace for the attributes of the elements. – Bhavna Jan 02 '18 at 09:33
  • I have raised a issue under the node module repository and this is now fixed by the repository owners. – Bhavna Apr 07 '18 at 18:45

1 Answers1

0

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.

Bhavna
  • 29
  • 5