http://www.perlmonks.org?node_id=344876

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

Hello all, I have a very small piece of code I have been struggling with and I am wondering if anyone has any insight. I have a WSDL definition from a .NET service of
http://www.thedialogcenter.com/EncryptionService.wsdl
The service is out of my control. I am using SOAP::Lite. I am not very familiar with SOAPs architecture and I have really never used it before. I have had success with every test service I used (from the SOAP documentation I was using - plus a java one we created ourselves), but not with this one. I do not get anything back. The code I used is as follows:
print SOAP::Lite -> uri('http://www.arkbluecross.com/WebServices/EncryptionService/ +Encrypt') -> service('http://thedialogcenter.com/EncryptionService.wsdl') -> Encrypt('43877AF844D640A189E5708F3BE9222E', 'Testing');
The code appears to run, but does not print anything. I have a tool called SOAPscope that I ran against this same .WSDL and it returned an encrypted string. I'm not sure if I am missing something simple. I know SOAP::Lite says it does not support complex return types, but this just comes back as a string (according to SOAPscope). I will take any advice you have to offer. Maybe I am getting failure return codes, but I don't know how to check them or maybe the data is coming back and Perl does not know how to handle it. Also, so there is no confusion, every other test I ran I used
->proxy() instead of ->service()
and in that proxy I put the name and location of the service. In this case the service is putting out a bogus .wsdl so I modified it to better reflect the service. I used SOAPscope to test with the .WSDL I created and it works as hoped. Thanks.

Replies are listed 'Best First'.
Re: SOAP Client
by rob_au (Abbot) on Apr 14, 2004 at 02:43 UTC
    Okay, the following is the SOAP client which I mocked up to test this WSDL - Note that I have deliberately obscured your customer ID number in the example below.
    #!/opt/bin/perl use SOAP::Lite +trace; my $result = SOAP::Lite ->service('http://www.thedialogcenter.com/EncryptionService.ws +dl') ->Encrypt('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Testing'); print $result, "\n";
    Including the SOAP::Lite trace showed me that the following request was sent to the location https://secure.arkansasbluecross.com/WebServices/EncryptionService.asmx.
    Accept: text/xml Accept: multipart/* Content-Length: 529 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://www.arkbluecross.com/WebServices/EncryptionService +/Encrypt" <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-EN +C="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://sc +hemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/X +MLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP +-ENV:Body><Encrypt xmlns=""><parameters>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx +xxx</parameters><c-gensym4 xsi:type="xsd:string">Testing</c-gensym4>< +/Encrypt></SOAP-ENV:Body></SOAP-ENV:Envelope>
    To this, the server responded:
    Cache-Control: private Date: Wed, 14 Apr 2004 02:34:05 GMT Server: Microsoft-IIS/5.0 Content-Length: 984 Content-Type: text/xml; charset=utf-8 Client-Date: Wed, 14 Apr 2004 02:35:30 GMT Client-Peer: 209.184.52.154:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU +=VeriSign International Server CA - Class 3/OU=www.verisign.com/CPS I +ncorp.by Ref. LIABILITY LTD.(c)97 VeriSign Client-SSL-Cert-Subject: /C=US/ST=Arkansas/L=Little Rock/O=Arkansas Bl +ue Cross and Blue Shield A Mutual Insurance Company/OU=Infrastructure + Management/OU=Terms of use at www.verisign.com/rpa (c)00/CN=secure.a +rkansasbluecross.com Client-SSL-Cipher: RC4-MD5 Client-SSL-Warning: Peer certificate not verified X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http +://www.w3.org/2001/XMLSchema"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>System.Web.Services.Protocols.SoapException: Server + was unable to process request. ---&gt; System.ArgumentNullException: + ArgumentNull_String Parameter name: g at System.Guid..ctor(String g) at ABCBS.IWD.WebServices.EncryptionService.GetCustomerKeys(String C +ustID, Int32 Timeout) in C:\Projects\Common\WebServicesSolution\WebSe +rvices\EncryptionService.asmx.vb:line 104 at ABCBS.IWD.WebServices.EncryptionService.Encrypt(String CustID, S +tring Data) in C:\Projects\Common\WebServicesSolution\WebServices\Enc +ryptionService.asmx.vb:line 50 --- End of inner exception stack trace ---</faultstring> <detail /> </soap:Fault> </soap:Body> </soap:Envelope>
    It would appear that SOAP::Lite is failing to encode the customer ID parameter correctly. Whilst this doesn't answer your question as to how to solve this problem, it may provide you with some additional information in your search for an answer. Note that there are still some gaps in the WSDL implementation in SOAP::Lite and as such, you may be better off to specify the service details manually or build the body using SOAP::Data::Builder.

     

    perl -le "print unpack'N', pack'B32', '00000000000000000000001011001110'"

      Thank you very much for the detailed write up. I am going to do what you did to see what happened in translation and try a few things. Thanks for obscuring my key, it was only a demo given out to me so I can test the service. I do believe I am closer than I was before because I did not know anything about the trace prior. Again thanks for your effort and my education.
        Just as a follow-up, I continued to play with SOAP::Data::Builder to see if I could build a successful request - To this end, I have the following code:
        #!/opt/bin/perl use SOAP::Data::Builder; use SOAP::Lite +trace; my $builder = SOAP::Data::Builder->new; $builder->add_elem( 'name' => 'parameters' ); $builder->add_elem( 'name' => 'CustID', 'parent' => $builder->get_elem('parameters'), 'value' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ); $builder->add_elem( 'name' => 'Data', 'parent' => $builder->get_elem('parameters'), 'value' => 'Testing' ); my $result = SOAP::Lite ->service('http://www.thedialogcenter.com/EncryptionService.ws +dl') ->Encrypt( $builder->to_soap_data ); print $result, "\n";
        ... which produces the following well-formed request ...
        Accept: text/xml Accept: multipart/* Content-Length: 558 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://www.arkbluecross.com/WebServices/EncryptionService +/Encrypt" <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-EN +C="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle= +"http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://sc +hemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/X +MLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP +-ENV:Body><Encrypt xmlns=""><parameters><CustID xsi:type="xsd:string" +>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</CustID><Data xsi:type="xsd:string" +>Testing</Data></parameters></Encrypt></SOAP-ENV:Body></SOAP-ENV:Enve +lope>
        However, whilst I haven't achieved a successful result, I have been able to build a well-formed SOAP request to dispatch to the service. If you can get a copy of a successful request generated by other means, it may be worth playing with SOAP::Data::Builder further to fashion a successful perl client.

         

        perl -le "print unpack'N', pack'B32', '00000000000000000000001011001111'"

      I must be a little dense because I just copied you exact code into my script and I did not get any thing returned with trace - the browser showed nothing. I will have to attempt again in the AM.
Re: SOAP Client
by esskar (Deacon) on Apr 14, 2004 at 02:35 UTC
    hi... have u tried turning the debuging on?
    SOAP::Trace provides you with a trace/debug facility for the SOAP::Lit +e library. To activate it you need to specify a list of traceable eve +nts/parts of SOAP::Lite: use SOAP::Lite +trace => qw(list of available traces here);Available events are: transport -- (client) access to request/response for transport layer dispatch -- (server) shows full name of dispatched call result -- (server) result of method call parameters -- (server) parameters for method call headers -- (server) headers of received message objects -- (both) new/DESTROY calls method -- (both) parameters for '->envelope(method =>' call fault -- (both) parameters for '->envelope(fault =>' call freeform -- (both) parameters for '->envelope(freeform =>' call trace -- (both) trace enters into some important functions debug -- (both) details about transportFor example: use SOAP::Lite +trace => qw(method fault);
      Thanks for the trace info, I have never tried it, but I will. Thanks again.