tags:

views:

36

answers:

3

EDIT: THIS QUESTION IS INVALID SINCE THE SERVER I'M USING HAS SUDDENLY EXPIRED. PLEASE IGNORE

I'm new to SoapClient in PHP, and I'm trying to fetch a PDF by passing three parameters and grabbing the result. Here's the WSDL file I'm working with (I don't really have much/any control over this part):

<!-- this WSDL file was automatically generated by 4D --> 
<definitions name="A_WebService" targetNamespace="http://www.4d.com/namespace/default" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.4d.com/namespace/default" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; 
    <message name="WS_ME_StatementRequest"> 
        <part name="FuneralHomeID" type="xsd:string"/> 
        <part name="Month" type="xsd:int"/> 
        <part name="Year" type="xsd:string"/> 
    </message> 
    <message name="WS_ME_StatementResponse"> 
        <part name="StatementPDF" type="xsd:base64Binary"/> 
    </message> 
    <portType name="A_WebServiceRPC"> 
        <operation name="WS_ME_Statement"> 
            <input message="tns:WS_ME_StatementRequest"/> 
            <output message="tns:WS_ME_StatementResponse"/> 
        </operation> 
    </portType> 
    <binding name="A_WebServiceBinding" type="tns:A_WebServiceRPC"> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" /> 
        <operation name="WS_ME_Statement"> 
<documentation>Inputs: None
Outputs: text variable</documentation> 
            <soap:operation soapAction="A_WebService#WS_ME_Statement"/> 
            <input> 
                <soap:body use="encoded" namespace="http://www.4d.com/namespace/default" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt; 
            </input> 
            <output> 
                <soap:body use="encoded" namespace="http://www.4d.com/namespace/default" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt; 
            </output> 
        </operation> 
    </binding> 
    <service name="A_WebService"> 
        <documentation></documentation> 
        <port name="A_WebServicePort" binding="tns:A_WebServiceBinding"> 
            <soap:address location="http://69.128.94.30:8080/4DSOAP/"/&gt; 
        </port> 
    </service> 
</definitions> 

And here's what I have so far which is just returning 404's:

<?php 

header("content-type: application/pdf");

$client = new SoapClient('http://69.128.94.30:8080/4DSOAP/');
$result = $client->WS_ME_StatementRequest(array('FuneralHomeID' => '0008-00', 'Month' => 11, 'Year' => "2008"));
$pdfdoc = $result->WS_ME_StatementResponse->StatementPDF;
print($pdfdoc);

Any ideas on what I'm doing wrong?

+1  A: 

At first glance it looks like the SoapClient url is wrong. Try:

$client = new SoapClient('http://69.128.94.30:8080/4DSOAP/'); 
Fosco
Ah that was the fault of me copying/pasting after changing that as a test. Sadly, doesn't change anything. I fixed it in the OP.
Mike Crittenden
+1  A: 

Looks like it's base64 encoded..

header("content-type: application/pdf");

$client = new SoapClient('http://69.128.94.30:8080/4DSOAP/');
$result = $client->WS_ME_StatementRequest(array('FuneralHomeID' => '0008-00', 'Month' => 11, 'Year' => "2008"));
echo base64_decode($result->WS_ME_StatementResponse->StatementPDF);
Kieran Allen
Thanks. Did you try that, by any chance? I just tried it and it didn't seem to change anything.
Mike Crittenden
I can't i get an expiry message.. Try writing it to a binary file! That expiry message looks like a server error.. You might want to double check you're not querying against an expired product first ;) SEE: http://69.128.94.30:8080/4DSOAP/ in your browser.
Kieran Allen
@Kieran, yep, the server appears to have expired since posting this. Great timing eh? Anyways, I updated the OP to tell people to ignore this question since we can't test right now.
Mike Crittenden
+1  A: 

I can't test this since I can't access your web service (paste it into your browser and it says its expired) but I believe you need to specify a content length and disposition in your headers.

$length = strlen($pdfdoc);
header("Content-type: application/pdf");
header("Content-Length: $length");
header("Content-Disposition: attachment; filename=myfile.pdf");
Jarrod