Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

SOAP::Lite, but not the problem?

by justshootme (Initiate)
on Nov 09, 2007 at 23:30 UTC ( #650014=perlquestion: print w/replies, xml ) Need Help??

justshootme has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, we have 2 machines here, one dev running Perl 5.6.1 (redhat 7.3), and one prod running Perl 5.8.4 (Debian sarge).

In trying to submit a SOAP::Lite request ( installed version shows as 'not defined' on RedHat), but it works fine.

On Debian (current SOAP::Lite v0.69) I keep receiving 'invalid namespace envelope element' as a reply.

Code is identical on both machines. I tried copying over the RedHat SOAP to 'Soapdev' and renaming all. Using that module I get the same error of namespace, so the error does not seem to be in SOAP::Lite . EG code -

my $xml_post = qq~ <upper1> <var1>val1</var1> <var2>val2<var2> </upper1> ~;
use SOAP::Lite +trace => 'debug';
my $soap = SOAP::Lite
->service ('http://www.path_to_wsdl'); # Microsoft .Net service
my $post_result = $soap->MethodCall($xml_post);


As an example the version of Net::FTP on RedHat is 2.65 and on Debian is 2.75, and obviously there may be other differences in installed modules.. just wondering if anyone has a direction to point in? Using RH 7.3 in production is not an option. Very little hair remaining due to this!
many thanks
Chris

Replies are listed 'Best First'.
Re: SOAP::Lite, but not the problem?
by erroneousBollock (Curate) on Nov 10, 2007 at 02:51 UTC
    we have 2 machines here, one dev running Perl 5.6.1 (redhat 7.3), and one prod running Perl 5.8.4 (Debian sarge).
    Right! RedHat... there's your problem right there ;)

    (I'm) trying to submit a SOAP::Lite request ( installed version shows as 'not defined' on RedHat), but it works fine.
    What exactly shows as 'not defined'? rpm doesn't ever say that to the best of my knowledge. On the RedHat box, what does this print?:

       perl -MSOAP::Lite -e 'print "$SOAP::Lite::VERSION\n"'

    On Debian (current SOAP::Lite v0.69) I keep receiving 'invalid namespace envelope element' as a reply.
    You're probably constructing an invalid SOAP document.

    Code is identical on both machines. I tried copying over the RedHat SOAP to 'Soapdev' and renaming all. Using that module I get the same error of namespace, so the error does not seem to be in SOAP::Lite
    Ouch! Don't do that. Either use the package management system (apt/yum) of your Linux distribution, or use the cpan shell, but please don't do that. First thing to do is have apt re-install v0.69.

    use SOAP::Lite +trace => 'debug'; my $xml_post = qq~<upper1><var1>val1</var1><var2>val2<var2></upper1> +~; my $soap = SOAP::Lite ->service('http://www.path_to_wsdl'); # Microsoft.Net service my $post_result = $soap->MethodCall($xml_post);
    Could you post your WSDL? I'm always very doubtful when I see folks passing fragments of XML to a SOAP method call as a parameter... contrary to the point of SOAP RPC/*. Also SOAP::Lite's service() method doesn't really work for services expecting complex types... for that you'll need SOAP::WSDL.

    Also, I see that you've enabled 'trace'; fantastic! Could you please post the two versions of the request, labelling them as 'debian' and 'redhat'?

    As an example the version of Net::FTP on RedHat is 2.65 and on Debian is 2.75, and obviously there may be other differences in installed modules.
    That's completely irrelevant.

    just wondering if anyone has a direction to point in? Using RH 7.3 in production is not an option. Very little hair remaining due to this!
    I've no idea why you'd use ancient nasty cruft like that in development... it's a really good idea to have identical dev/prod environments though, so just ditch RedHat and install Sarge there.

    If you post what I asked for above, we can probably help you fix your issues on Debian.

    -David

      What exactly shows as 'not defined'? rpm doesn't ever say that to the best of my knowledge.
      'i SOAP::Lite' on CPAN gave me undefined as currently installed
      On the RedHat box, what does this print?: perl -MSOAP::Lite -e 'print "$SOAP::Lite::VERSION\n"'
      0.69
      Could you post your WSDL
      WSDL below - note not mine- Beanstream's -


      <?xml version='1.0' encoding='UTF-8' ?> <definitions name ='ProcessTransaction' targetNamespace = 'http://tempuri.org/wsdl/' xmlns:wsdlns='http://tempuri.org/wsdl/' xmlns:typens='http://tempuri.org/type' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension' xmlns='http://schemas.xmlsoap.org/wsdl/'> <types> <schema targetNamespace='http://tempuri.org/type' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' elementFormDefault='qualified'> </schema> </types> <message name='TransClass.TransactionProcess'> <part name='inputTrans' type='xsd:string'/> </message> <message name='TransClass.TransactionProcessResponse'> <part name='Result' type='xsd:string'/> </message> <message name='TransClass.TransactionProcessAuth'> <part name='inputTrans' type='xsd:string'/> </message> <message name='TransClass.TransactionProcessAuthResponse'> <part name='Result' type='xsd:string'/> </message> <portType name='TransClassSoapPort'> <operation name='TransactionProcess' parameterOrder='inputTrans'> <input message='wsdlns:TransClass.TransactionProcess' /> <output message='wsdlns:TransClass.TransactionProcessResponse' /> </operation> <operation name='TransactionProcessAuth' parameterOrder='inputTrans'> <input message='wsdlns:TransClass.TransactionProcessAuth' /> <output message='wsdlns:TransClass.TransactionProcessAuthResponse' /> </operation> </portType> <binding name='TransClassSoapBinding' type='wsdlns:TransClassSoapPort' > <stk:binding preferredEncoding='UTF-8'/> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' /> <operation name='TransactionProcess' > <soap:operation soapAction='http://tempuri.org/action/TransClass.TransactionProcess' /> <input> <soap:body use='encoded' namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </input> <output> <soap:body use='encoded' namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </output> </operation> <operation name='TransactionProcessAuth' > <soap:operation soapAction='http://tempuri.org/action/TransClass.TransactionProcessAuth' /> <input> <soap:body use='encoded' namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </input> <output> <soap:body use='encoded' namespace='http://tempuri.org/message/' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' /> </output> </operation> </binding> <service name='ProcessTransaction' > <port name='TransClassSoapPort' binding='wsdlns:TransClassSoapBinding' > <soap:address location='https://www.beanstream.com/soap/ProcessTransaction.wsdl' /> </port> </service> </definitions>

      *******end Wsdl

      Redhat Trace******************************

      SOAP::Transport::HTTP::Client::send_receive: POST https://www.beanstream.com/soap/ProcessTransaction.wsdl HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 1528 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://tempuri.org/action/TransClass.TransactionProcess"

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://sch emas.xmlsoap.org/soap/envelope/" xmlns:wsdlns="http://tempuri.org/wsdl/" xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsd l-extension" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi ng/" xmlns:typens="http://tempuri.org/type" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:namesp1="http://tempuri.org/messag e/">
      <soap:Body><namesp1:TransactionProcess><inputTrans xsi:type="xsd:string"> <transaction> <merchant_id>XXXXXXXXXXXXX</merchant_id> <trnType>PA</trnType> <trnCardOwner>myname</trnCardOwner> <trnCardNumber>4030000010001234</trnCardNumber> <trnExpMonth>01</trnExpMonth> <trnExpYear>09</trnExpYear> <trnAmount>1.00</trnAmount> <trnCardCvd>123</trnCardCvd> <ordEmailAddress>sdfgf@glbcom.net</ordEmailAddress> <ordName>LFirstName LLastName</ordName> <ordPhoneNumber>6048745874</ordPhoneNumber> <ordAddress1>my addr</ordAddress1> <ordAddress2></ordAddress2> <ordCity>city</ordCity> <ordProvince>MB</ordProvince> <ordPostalCode>90210</ordPostalCode> <ordCountry>CA</ordCountry> <trnCurrency>USD</trnCurrency> </transaction> </inputTrans></namesp1:TransactionProcess></soap:Body></soap:Envelope>

      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Fri, 09 Nov 2007 22:04:48 GMT Server: Microsoft-IIS/5.0 Content-Length: 789 Content-Type: text/xml; charset="UTF-8" Expires: -1; Client-Date: Fri, 09 Nov 2007 22:04:48 GMT Client-Peer: 139.142.123.254:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=US/O=Equifax/OU=Equifax Secure Certificate Authority Client-SSL-Cert-Subject: /C=CA/ST=BC/L=Victoria/O=Beanstream/OU=Beanstream Internet Commerce Inc/CN=www.beanstream.com Client-SSL-Cipher: RC4-MD5 Client-SSL-Warning: Peer certificate not verified X-Powered-By: ASP.NET <?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns: SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="h ttp://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP SDK4:TransactionProcessResponse xmlns:SOAPSDK4="http://tempuri.org/message/"><Result><response><trnId>10000896</tr nId><trnApproved>1</trnApproved><messageId>1</messageId><messageText>Approved</messageText> ;<trnAuthCode>TEST</trnAuthCode></response></Result></SOAPSDK4:TransactionProcessResponse></SOAP-ENV:Body></SOA P-ENV:Envelope> r = <response><trnId>10000896</trnId><trnApproved>1</trnApproved><messageId>1</messageId><messageText>Approved</messageText><trnA uthCode>TEST</trnAuthCode></response>

      END RED HAT TRACE ****************************

      DEBIAN Trace ***********************************

      SOAP::Transport::HTTP::Client::send_receive: POST https://www.beanstream.com/soap/ProcessTransaction.wsdl HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 1530 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://tempuri.org/action/TransClass.TransactionProcess"

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:namesp1="http://tempuri.org/message/" xmlns:stk="http://schemas.micros oft.com/soap-toolkit/wsdl-extension" xmlns:typens="http://tempuri.org/type" soap:encodingStyle="http://schemas.xmlsoap.org/soap/e ncoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdlns="http://tempuri.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body><namesp1:TransactionProcess><inputTrans xsi:type="xsd:string"> <transaction> <merchant_id>XXXXXXXXXXXX</merchant_id> <trnType>PA</trnType> <trnCardOwner>mynam</trnCardOwner> <trnCardNumber>5100000010001004</trnCardNumber> <trnExpMonth>01</trnExpMonth> <trnExpYear>10</trnExpYear> <trnAmount>1.00</trnAmount> <trnCardCvd>123</trnCardCvd> <ordEmailAddress>ghguiq@glbcom.net</ordEmailAddress> <ordName>LFirstName LLastName</ordName> <ordPhoneNumber>8745874521</ordPhoneNumber> <ordAddress1>715 etr</ordAddress1> <ordAddress2>street</ordAddress2> <ordCity>city</ordCity> <ordProvince>AR</ordProvince> <ordPostalCode>90210</ordPostalCode> <ordCountry>US</ordCountry> <trnCurrency>USD</trnCurrency> </transaction> </inputTrans></namesp1:TransactionProcess></soap:Body></soap:Envelope>

      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error Connection: close Date: Tue, 13 Nov 2007 17:22:37 GMT Server: Microsoft-IIS/5.0 Content-Length: 1681 Content-Type: text/xml; charset="UTF-8" Expires: -1; Client-Date: Tue, 13 Nov 2007 17:22:37 GMT Client-Peer: 139.142.123.250:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: /C=US/O=Equifax/OU=Equifax Secure Certificate Authority Client-SSL-Cert-Subject: /C=CA/ST=BC/L=Victoria/O=Beanstream/OU=Beanstream Internet Commerce Inc/CN=www.beanstream.com Client-SSL-Cipher: RC4-MD5 Client-SSL-Warning: Peer certificate not verified X-Powered-By: ASP.NET <?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns: SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="h ttp://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP -ENV:Fault><faultcode>SOAP-ENV:VersionMismatch</faultcode><faultstring>VersionMismatch:The Soap processor found an invalid namesp ace for the SOAP Envelope element.</faultstring><detail><mserror:errorInfo xmlns:mserror="http://schemas.microsoft.com/soap-toolk it/faultdetail/error/"><mserror:returnCode></mserror:returnCode><mserror:serverErrorInfo><mserror:description>VersionMismatch:The Soap processor found an invalid namespace for the SOAP Envelope element. HRESULT=0x800A1BBD - Server:An unanticipated error occu rred during the processing of this request. HRESULT=0x800A1BBD</mserror:description><mserror:source>VersionMismatch</mserror:sour ce></mserror:serverErrorInfo><mserror:callStack><mserror:callElement><mserror:component>VersionMismatch</mserror:component><mserr or:description>The Soap processor found an invalid namespace for the SOAP Envelope element.</mserror:description><mserror:returnC ode></mserror:returnCode></mserror:callElement><mserror:callElement><mserror:component>Server</mserror:component><mserror:descrip tion>An unanticipated error occurred during the processing of this request.</mserror:description><mserror:returnCode></mserror:re turnCode></mserror:callElement></mserror:callStack></mserror:errorInfo></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envel ope>

      ****************END DEBIAN TRACE *************

      I've no idea why you'd use ancient nasty cruft like that in development...
      It works, and Debian currently doesn't currently? ;-) just kidding..


      the one thing I see is that RH reads it as 1528, and deb as 1530, and the order of the header fields are slightly different
      many many thanks for any help..
      Chris
        It took me a while to post this because I had to do so much reformatting of the messages you posted. I realise you can't control the output of the SOAP::Lite trace, nor the WSDL from the ASP.net server... but I do have two suggestions:
        • Use xmltidy from the XML::Tidy distribution to clean up XML before posting.
        • Read Writeup Formatting Tips... especially concerning the use of <code> and <readmore> tags.

        Notes

        You didn't send identical messages, so I've corrected your debian request to have the same data (underneath TransactionProcess) as the redhat request. I also re-ordered the attributes of the soap-envelope node in the debian request so it would be easier to make a comparison.

        Let's have a look at the two requests as per the trace you posted:

        RedHat request

        Debian request

        Differences

        I saved the two requests into separate files and ran diff over them:

        bollock@localhost [~] diff -u redhat_request.xml debian_request.xml --- redhat_request.xml 2007-11-14 12:39:48.000000000 +1000 +++ debian_request.xml 2007-11-14 12:48:27.000000000 +1000 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:wsdlns="http://tempuri.org/wsdl/" - xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extensi +on" - soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:typens="http://tempuri.org/type" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:wsdlns="http://tempuri.org/wsdl/" + xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extensi +on" + soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" + xmlns:typens="http://tempuri.org/type" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:namesp1="http://tempuri.org/message/"> <soap:Body> <namesp1:TransactionProcess>
        The differing lines are:

        - xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        So your two installations are sending differing 'soap' namespace values. Let's look at the SOAPFault you received back from the server for the debian request:

        Soap Fault

        You can see that it's complaining about exactly the difference I noted above.

        I've reformatted the opening section of the WSDL you posted:

        Posted WSDL

        As you can clearly see, the WSDL contains exactly the same 'soap' namespace element as was sent by the 'debian' SOAP::WSDL request.

        At first I thought that perhaps the web-service was serving different versions of the WSDL document, and you did mention some difference in message sizes; However, the size difference was because of the differing namespace in the request. To make sure I was always getting the same WSDL document, I downloaded it directly.

        The service port node specifies https://www.beanstream.com/soap/ProcessTransaction.wsdl as the URL serving the WSDL document:

        <service name="ProcessTransaction"> <port name="TransClassSoapPort" binding="wsdlns:TransClassSoapBind +ing"> <soap:address location="https://www.beanstream.com/soap/ProcessT +ransaction.wsdl" /> </port> </service>
        Using firefox or wget, I can only get it to serve WSDL containing the "bad" namespace attribute.

        Are you sure both installations have SOAP::Lite version 0.69, SOAP::WSDL v1.22+, and that they're both receiving the same WSDL?

        If that's true and the RedHat installation sends a different request, then RedHat might have patched either SOAP::Lite or SOAP::WSDL for distribution (not unheard of). You can force the cpan shell to install over what you have to make sure they're the same.

        Conclusions

        The real problem as I see it, is that the web-service responds with valid WSDL, which the debian version uses in an entirely appropriate manner, and then the web-service responds that it doesn't like that namespace attribute. :-(

        Have a look at the SOAP::Lite and SOAP::WSDL APIs to see if they allow you to manually override Envelope namespace attributes. If so, that should solve your problem. But really, based on my investigation, it's the server that is at fault.

        -David

      Hi David, thanks for the offer - I'll post it tomorrow (it's remembrance day here today) Chris

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://650014]
Approved by saberworks
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2019-11-17 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (86 votes). Check out past polls.

    Notices?