Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOAP multirefs #44

Open
droyo opened this issue Oct 27, 2017 · 3 comments
Open

SOAP multirefs #44

droyo opened this issue Oct 27, 2017 · 3 comments

Comments

@droyo
Copy link
Owner

droyo commented Oct 27, 2017

Let's talk about the elephant in the room: references in SOAP documents. We can generate the greatest type declarations ever, but that won't do us any good in the face of documents such as this:

<Body>
  <multiRef id="obj0" soapenc:root="0" xsi:type="myNS:Part">
    <sku>SJ-47</sku>
  </multiRef>

  <response>
    <arg href="#obj0"/>
  </response>
</Body>

ugh. What's worse, one of the explicit reasons listed in the SOAP spec for references is to support data models that include loops. A loop would cause some problems if we simply tried to flatten a document.

A long time ago I wrote a tiny package that took the "flattening" approach: aqwari.net/exp/soap. That's one approach.

  • Should I bundle flattening code with the generated code for wsdlgen? Seems a little heavy.
  • Make a package to handle the references? I like that today, code generated by xsdgen and wsdlgen has no dependencies outside of the stdlib.

What I am leaning towards is developing a standalone package that users can choose to add to their generated packages if they know they're going to be dealing with references. Something that wraps an xml.Decoder and decodes a document as if it were flattened (while still handling loops in a sane way if possible). That package should have more stringent release engineering/compatibility guarantees, since it will be imported in users' code. But I haven't started this package, so I'm keeping an issue here so I don't forget.

@RoniLevin
Copy link

Hi,
This is a great package! Unfortunately I need to parse messages with multirefs. Do you have any updates on this issue?

@droyo
Copy link
Owner Author

droyo commented Jan 3, 2018

I started work on the multiref branch, but unfortunately I am not close to resolving this issue, and will have limited time to make progress for the next month or so.

If your inputs do not contain loops, you cloud get this package to work using the "flattening" approach:

  • Read the whole input into a []byte
  • Use a package like aqwari.net/exp/soap to replace any multi refs with their content, or write your own routine to do this.
  • Turn the []byte back into an io.Reader using bytes.NewReader or similar and pretend nothing ever happened :)

@RoniLevin
Copy link

The flattening approach works great. Thank!
Hope to see the the support for multiref added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants