lula / ngx-soap

Simple SOAP client for Angular
MIT License
66 stars 61 forks source link

object Object in xml tags #18

Closed ZieClaw closed 5 years ago

ZieClaw commented 6 years ago

I use this variable as my body, as you can see it has a nested object as Magento requires it to be passed this way. And the result was good except for the fact that in customerData the data lines all had [object Object] added to them, like this <email[object Object]>this.email and this is not valid XML. let body = { 'sessionId' : this.apiKey, 'customerData': { email: this.email, firstname: this.voornaam, lastname: this.achternaam, middlename: this.tussenvoegsel, password: this.wachtwoord, dob: this.geboortedatum, gender: this.geslacht, send_new_account_email: 1, customer_activated: 0, }};

I have already fixed it by string replacing the [object Object] parts but this is not proper behavior of course.

lula commented 6 years ago

Mmm what is exactly your problem? You see this <email[object Object]>this.email in the payload? Can you somehow create a plunkr where I can check?

ZieClaw commented 6 years ago

Yes the [object Object] tags are in the operation.xml payload. They are present for all the objects in the customerData object, so from email to customer_activated.

It only happens with nested objects. I'll try and make a plunkr, when I have the time for it.

Here is the generated XML:

2deb9f7dd8862836d4626feb02d1496ftest@test.nltesttest1234562018-06-1812310
lula commented 6 years ago

Hello @ZieClaw! Can you perhaps try with the new branch lib? See here

lula commented 6 years ago

@ZieClaw I had some further tests using the latest version.

json body:

const body: any = {
      CustomerSelectionByElements: {
        SelectionByCategoryCode: {
          InclusionExclusionCode: 'I',
          IntervalBoundaryTypeCode: categoryCode ? 1 : 3,
          LowerBoundaryCategoryCode: categoryCode || 1,
          UpperBoundaryCategoryCode: categoryCode ? '' : 2
        },
      },
      ProcessingConditions: {
        QueryHitsMaximumNumberValue: maxResults || 10,
        QueryHitsUnlimitedIndicator: false
      }
    };

and the generated xml:

<n2:CustomerByElementsQuery_sync xmlns:n2="http://sap.com/xi/SAPGlobal20/Global">
    <CustomerSelectionByElements>
        <SelectionByCategoryCode>
            <InclusionExclusionCode>I</InclusionExclusionCode>
            <IntervalBoundaryTypeCode>1</IntervalBoundaryTypeCode>
            <LowerBoundaryCategoryCode>2</LowerBoundaryCategoryCode>
            <UpperBoundaryCategoryCode></UpperBoundaryCategoryCode>
        </SelectionByCategoryCode>
    </CustomerSelectionByElements>
    <ProcessingConditions>
        <QueryHitsMaximumNumberValue>5</QueryHitsMaximumNumberValue>
        <QueryHitsUnlimitedIndicator>false</QueryHitsUnlimitedIndicator>
    </ProcessingConditions>
</n2:CustomerByElementsQuery_sync>

If I've understood well your problem, it seems to be solved now.

Please let me know.

You can download version 0.5.0-beta.2 from npm.

Cheers!

ZieClaw commented 6 years ago

@lula I will try this new version once I get back from my holiday next month and let you know if this fixes the issue for me. From your example though I say it should be fixed.

lula commented 6 years ago

@ZieClaw thanks and enjoy your holidays!!! 🏖