foomo / soap

SOAP is dead, long live SOAP
MIT License
24 stars 36 forks source link

Client.Call() check for "<soap" or "<SOAP" tag invalidates XML body #6

Open imadu opened 3 years ago

imadu commented 3 years ago

First off I'd like to say a big thank you to the makers of this package, your work has helped save my a lot of time in setting up my soap server and client.

However when using the client, to make a call (i.e. client.Call(...)) I get a This is not a SOAP-Message error even when sending valid XML envelopes. I did some digging around and I found this line of code below in the client.go file:

if !(strings.Contains(string(rawbody), "<soap") || strings.Contains(string(rawbody), "<SOAP")) {
            l("This is not a SOAP-Message: \n" + string(rawbody))
            return nil, errors.New("This is not a SOAP-Message: \n" + string(rawbody))
        }

This checks to see if the incoming SOAP envelope has either a "<soap"or "<SOAP" tag anywhere in the response envelope. I'd like to know first of all why this is important to check for, as some of SOAP envelopes do not contain a soap prefix at all, as see in this example below:

<?xml version="1.0" encoding="UTF-8" ?>
 <NESingleResponse>
<SessionID>000001100913103301000000000001</SessionID> <DestinationInstitutionCode>000002</DestinationInstitutionCode> 
<ChannelCode>1</ChannelCode> 
<AccountNumber>2222000000012345</AccountNumber> 
<AccountName>Ajibade Oluwasegun</AccountName> 
<BankVerificationNumber>1033000441</BankVerificationNumber> 
<KYCLevel>1</KYCLevel>
<ResponseCode>00</ResponseCode>
 </NESingleResponse>

And also can this be removed? so that Envelopes as given in the example below can be parsed as well.

Thank you very much

florianschlegel commented 3 years ago

Hi, the check is indeed a bit sloppy. However, if I am not mistaken your xml is not valid SOAP since it's not using the SOAP namespace. If you need a quick solution I would suggest that you just create a fork and adjust it to your needs since we have no capacity right now to dig into this deeper.