savonrb / savon

Heavy metal SOAP client
https://www.savonrb.com
MIT License
2.07k stars 616 forks source link

XML Namespaces Injection Change Causing Unexpected Results #978

Closed aedryan closed 1 year ago

aedryan commented 2 years ago

Due to the change to inject all namespaces into the built XML, I'm seeing unexpected results in an API I am integrating with. It appears that prior to this change the xmlns and xmlns:soap namespaces were not included in the built XML despite their inclusion in my WSDL configuration. Now they are included and they appear to be clobbering something in the external API I'm integrating with. If I remove them from my WSDL config, the Savon client fails to find the operations and build anything.

I can find no callbacks, actions, or any way to get in between Savon and the builder of the XML except to manually build the XML and call the API using some of Savon's exposed classes.

I realize this is a bit of a funny issue to report and is likely the external API I'm integrating with that is at fault here, I can really only provide the XSD I have for that which is here: https://vintelligence.ihsmarkit.com/vindecoder/VinDecoderService_schema1.xsd

If I had some way to get in between the XML building when calling an operation from the client or some setting to more explicitly control which namespaces are injected into the build XML that would help me move past this issue.

cooljl31 commented 2 years ago

I have the same problem with SOAP calls

The actual Request should look like this

<?xml version= \"1.0\" encoding= \"utf-8\"?>
<soapenv:Envelope xmlns:xsd= \"http://www.w3.org/2001/XMLSchema\" xmlns:xsi= \"http://www.w3.org/2001/XMLSchema-instance\" xmlns:types= \"http://dpd.com/common/service/types/LoginService/2.0\" xmlns:soapenv= \"http://schemas.xmlsoap.org/soap/envelope/\">
    <soapenv:Body>
        <types:getAuth>
            <delisId>delisId</delisId>
            <password>password</password>
            <messageLanguage>en_GB</messageLanguage>
        </types:getAuth>
    </soapenv:Body>
</soapenv:Envelope>

And now the request look like this with the new version 2.3.1, which cause the request to failed, because of those keys xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://dpd.com/common/service/LoginService/2.0" xmlns:types_authentication="http://dpd.com/common/service/types/Authentication/2.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:types="http://dpd.com/common/service/types/LoginService/2.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://dpd.com/common/service/LoginService/2.0" xmlns:types_authentication="http://dpd.com/common/service/types/Authentication/2.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <soapenv:Body>
        <types:getAuth>
            <delisId>delisId</delisId>
            <password>password</password>
            <messageLanguage>en_GB</messageLanguage>
        </types:getAuth>
    </soapenv:Body>
</soapenv:Envelope>

Would be nice if there was a way to optionally add them if someone needs them, otherwise they shouldn't be added by default. Actually, this is a breaking change, not really a minor release.

pcai commented 2 years ago

Sorry about that, it was not the intent for this to be backwards-breaking. I think you'll need to pin 2.12.x for now to avoid this issue.

If you have a wsdl and test case I may be able to look into it, otherwise someone affected by this will need to propose a patch, since I don't know where the precise behavior is deviating from spec.

pcai commented 1 year ago

Hi can either of you confirm if your problem reproduces if the "xmlns" attribute is omitted? I have prepared a candidate fix here:

https://github.com/savonrb/savon/commit/3859640069520c06b9320e43fda731f656bad75d

Can you give this a try and report back please? You should be able to give it a try like this in your Gemfile:

gem 'savon', github: 'savonrb/savon', ref: '3859640'

pcai commented 1 year ago

I believe this is a dupe of https://github.com/savonrb/savon/issues/986 which is fixed in https://github.com/savonrb/savon/pull/989 - a few folks mentioned worked for them. The patch is released as part of savon 2.14 so please reopen this with additional information if its still not working with that release version. thanks