How do I build a native PHP 5 SOAP client to consume a web service file download?

Our office is building a web service for file transfers to and from the server. We've built a web service in Java to facilitate the uploads/downloads on the server, however I need to build a PHP 5 client to consume the web service and move files in BOTH directions. I'm pulling my hair out with this. What am I missing!?!? I'm rather new to web services and SOAP (big surprise!).

The WSDL is delivering files in base64Binary and I need to upload them as such. I can instanciate the web service easy enough but I really cannot tell if the files are arriving as attachments in MIME or DIME. I don't think they're just showing up as an encoded XML stream because the $result is saying the XML response is empty. Obivously I'm missing something.

Also, NuSoap doesn't seem to be working with PHP 5, so this option is out. I need a native PHP 5 SOAP implementation. Any help with this would be very much appreciated AND I'm sure other folks would love to find this solution as well!!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You shouldn't need anything other than ext/soap.  If you're getting some sort of transfer, you might want to enable trace on your SoapClient instance, and check the __getLast*() methods if an error does get thrown.  What are you getting back in your  __getLastResponse() on the SoapClient instance?
solascripturaAuthor Commented:
Okay, here's what's being returned in the __getLastRequest() and __getLastResponse(). Any help with retrieving the file data in PHP code and then saving the file to disk would be greatly appreciated!  :)

Request :

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="x" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC="" SOAP-ENV:encodingStyle="">
                  <sFilename xsi:type="xsd:string">any</sFilename>


Content-Type: text/xml; charset=UTF-8
Content-Length: 506

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:xsi='' xmlns:xsd='' xmlns:soap='' xmlns:soapenc=''>
      <soap:Body soap:encodingStyle=''>
            <n:doRetrieveFileResponse xmlns:n='x'>
                  <Result href='cid:http://6FF7106E-E509-2BA1-9973-CD9344C53FE8'></Result>

Content-ID: <http://6FF7106E-E509-2BA1-9973-CD9344C53FE8>
Content-Length: 3126
Content-Type: application/binary

BM6 ýýýýýý6ýýý(ýýý ýýý ýýýýýýýýýý ýýýýýýý <snip for brevity> ýýýýýýýýýýýýýýýýýýýýýýý
Well, we can see why your $result is coming up blank:  The doRetrieveFile call returns no status code on successful completion.

What I see happening is that the file transferred, but as a MIME attachment (which is the extended string you see under the `Content-Type: application/binary`header in the Response).

You can either switch your code to use the SOAP package from PEAR, but it supports PHP4 and PHP5 and doesn't use native calls.    Alternatively, you could split the value of __getLastResponse() along the MIME_boundary and then pull out the binary data with base64_decode().  Not elegant, but I haven't seen much (if any) support for MIME attachments in ext/soap.
solascripturaAuthor Commented:
Okay, this may be an option to just break out the MIME from the __getLastResponse call, but that's rather ugly. I'll have a look at PEAR's implementation. How would I then UPLOAD the file, as an encoded base64 string?
solascripturaAuthor Commented:
I found an excellent open-source solution at This PHP extension library more or less covers what PHP SOAP and PEAR left out.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.