博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP通过soap调用c#的WebService
阅读量:4332 次
发布时间:2019-06-06

本文共 1739 字,大约阅读时间需要 5 分钟。

1:C#

Contact

public class Contact    {        private int _Id;        private string _Name;        public int id        {            get { return _Id; }            set { _Id = value; }        }        public string name        {            get { return _Name; }            set { _Name = value; }        }    }

WebService

[WebService(Namespace = "http://tempuri.org/")]    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]    [ToolboxItem(false)]    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.     // [System.Web.Script.Services.ScriptService]    public class Service1 : System.Web.Services.WebService    {        [WebMethod]        public string Function1(Contact Contact, string description, int amount)        {            string r = string.Format("receive request! id: {0}, name: {1}, description: {2}, amount: {3}", Contact.id, Contact.name, description, amount);            return r;        }    }

PHP

class Contact {    function Contact($id, $name)    {        $this->id = $id;        $this->name = $name;    }}try{/* Initialize webservice with your WSDL */$client = new SoapClient("http://10.241.204.121:8022/Service1.asmx?wsdl");/* Fill your Contact Object */$contact = new Contact(100, "John");/* Set your parameters for the request */$params = array(        "Contact" => $contact,        "description" => "snda",        "amount" => 10,);/* Invoke webservice method with your parameters, in this case: Function1 */$response = $client->__soapCall("Function1", array($params));/* Print webservice response */var_dump($response);} catch (Exception $e) {    echo 'Caught exception: ',  $e->getMessage(), "\n";}

 

转载于:https://www.cnblogs.com/tommyli/p/3165009.html

你可能感兴趣的文章
Mysql数据类型
查看>>
五险一金及个税计算器
查看>>
在安装DiscuzNT时出现“未能加载文件或程序集“Discuz.Forum”或它的某一个依赖项。系统找不到指定的文件”...
查看>>
调用有道词典翻译api
查看>>
Java进击C#——项目开发环境
查看>>
视图和布局
查看>>
"垃圾收集"之愚见 基本上是取自《javascript高级程序设计》的一个概括
查看>>
HDU 3507 Print Article
查看>>
[UVALive 4329] Ping pong
查看>>
Java基本输入输出
查看>>
python 2.43 升级到2.7
查看>>
bzoj3631 [JLOI2014]松鼠的新家
查看>>
C#之路开篇
查看>>
SQL Server 高性能写入的一些总结
查看>>
浏览器的类别及介绍
查看>>
矩阵的应用
查看>>
ZC_知识点
查看>>
jQuery 文档操作 - insertAfter() ,insertBefore(),after(),before() 方法
查看>>
Hybrid App
查看>>
sql server2008 r2 密钥
查看>>