开发者

Fetching a PDF file using SOAP and PHP

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"> 
    <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.xmlsoa开发者_StackOverflow社区p.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/"/> 
            </input> 
            <output> 
                <soap:body use="encoded" namespace="http://www.4d.com/namespace/default" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 
            </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/"/> 
        </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?


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);


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

$client = new SoapClient('http://69.128.94.30:8080/4DSOAP/'); 


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜