在PHP中使用.Net Web服务来接收文件流 [英] Using .Net webservice in PHP to receive file stream
本文介绍了在PHP中使用.Net Web服务来接收文件流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我在C#中有一个Web服务,该服务返回pdf文件.我在PHP中有另一个应用程序,它将调用此Web服务,并允许用户下载此pdf.
我的C#代码是
Hello,
i have a webservice in C# which return a pdf file. i have another application in PHP which will call this webservice and allow users to download this pdf.
my C# code is
[WebMethod]
public byte[] GetFile()
{
string fileName = @"D:\pdf\5.pdf";
byte[] filebytes = null;
using (FileStream fs = File.OpenRead(fileName))
{
filebytes = new byte[fs.Length];
fs.Read(filebytes, (int)0, (int)fs.Length);
}
return filebytes;
}
这是我用来消费的php代码
Here is the php code which i am using to consume
<?php
$client = new SoapClient("http://localhost:63547/Service1.asmx?WSDL");
$result = $client->GetSimple();
print_r($result);
?>
但它会返回如下内容
stdClass对象([GetSimpleResult] =>%PDF-1.6%crackpdf.com 1 0
请帮助我如何在php中使用它:)
But it returns some thing like following
stdClass Object ( [GetSimpleResult] => %PDF-1.6 %crackpdf.com 1 0
Please help how can i consume it in php :)
推荐答案
client = 新 SoapClient (" );
client = new SoapClient("http://localhost:63547/Service1.asmx?WSDL");
结果 =
result =
client-> GetSimple(); print_r(
client->GetSimple(); print_r(
这篇关于在PHP中使用.Net Web服务来接收文件流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文