PHP SOAP
<?php
$classmap = array();
//注意和实例一的不同
$soap = new SoapServer(null, array('uri' => "http://localhost", "classmap" => $classmap));
$soap->setClass('Myclass');
$soap->handle();
class Myclass
{
function say($someword)
{
return $someword;
}
}
?>
<?
try {
$client = new SoapClient(null, array('location' => "http://localhost/server.php",
'uri' => "http://localhost"));
//var_dump($client);
echo $client->say("xyz world");
}
catch (SoapFault $fault) {
echo "Error: ", $fault->faultcode, ", string: ", $fault->faultstring;
}
Internal Server Error
表示服务器验证出错
<?php // 服务器验证
if ($_SERVER['PHP_AUTH_USER'] != 'bo' || $_SERVER['PHP_AUTH_PW'] != 'bo') {
header('WWW-Authenticate: Basic realm="MyFramework Realm"');
header('HTTP/1.0 401 Unauthorized');
echo "You must enter a valid login ID and password to access this resource.\n";
exit;
} require ("soapHandle.class.php"); // 处理请求的class try {
$server = new SOAPServer(null, array('uri' => 'http://localhost/soap/server.php'));
$server->setClass('soapHandle'); //设置处理的class
$server->handle();
}
catch (SOAPFault $f) {
print $f->faultString; // 打印出错信息
} ?>
<?php class soapHandle{ public function strtolink($url=''){
return sprintf('<a href="%s">%s</a>', $url, $url);
} } ?>
<?php try {
$client = new SOAPClient(null, array(
'location' => 'http://localhost/soap/server.php', // 设置server路径
'uri' => 'http://localhost/soap/server.php',
'login' => 'bo', // HTTP auth login
'password' => 'bo' // HTTP auth password
)); echo $client->strtolink('http://blog.csdn.net/fdipzone') . '<br>'; // 直接调用server方法
echo $client->__soapCall('strtolink', array('http://blog.csdn.net/fdipzone')); // 间接调用server方法
}
catch (SOAPFault $e) {
print $e->getMessage();
} ?>
<?php$classmap = array();//注意和实例一的不同$soap = new SoapServer(null, array('uri' => "http://localhost", "classmap" => $classmap));$soap->setClass('Myclass');$soap->handle();class Myclass{ function say($someword) { return $someword; }}?>
PHP SOAP的更多相关文章
- 【接口开发】浅谈 SOAP Webserver 与 Restful Webserver 区别
接口,强大,简单,交互,跨越平台 下面简单阐述这两大接口思想 一 REST: REST是一种架构风格,其核心是面向资源,REST专门针对网络应用设计和开发方式,以降低开发的复杂性,提高系统的可伸缩性. ...
- salesforce 零基础学习(五十五)java通过SOAP方式定时访问某个文件然后插入到sObject中
项目源码:https://github.com/zhangyueqidlmu/SOAP-Access-SFDC.git 项目背景:salesforce端相关数据需要其他系统提供,其他系统可以提供相关数 ...
- infopath发布的提示“无法解析SOAP消息”(The SOAP message cannot be parsed)问题解决方案
最近发现一个列表数据过大,每次发布infopath表单提示如下错误: 后来发现一个infopath表单通过list.asmx and Formsservice.asmx来进行发布的. This err ...
- Rest webservice 和SOAP webservice
SOAP: 简单对象访问协议(Simple Object Access Protocol,SOAP)是一种基于 XML 的协议,可以和现存的许多因特网协议和格式结合使用,包括超文本传输协议(HTTP) ...
- webservice客户端添加soap Header信息
根据wsdl文件的header信息,在客户端中添加相应的header 1.wsdl信息如图 <soapenv:Envelope xmlns:soapenv="http://schema ...
- 推荐一篇 关于REST 和 SOAP区别的文章
写的很出色! https://www.ibm.com/developerworks/cn/webservices/0907_rest_soap/ 我的感觉就是REST针对的是资源,通过api的URL就 ...
- c/c++的Soap应用
1. 关于soap 在许多项目中团队中,我们常常会听到这样的话:我们这里是用webservice交互的.而说话的场景往往就是交互对象双方比较异构,所谓异构.即双方是不同的开发语言.不同的运行环境等.比 ...
- C# 通过模拟http请求来调用soap、wsdl
C#调用webservice的方法很多,我说的这种通过http请求模拟来调用的方式是为了解决C#调用java的远程API出现各种不兼容问题. 由于远程API不在我们的控制下,我们只能修改本地的调用代码 ...
- 彻底理解webservice SOAP WSDL
WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...
- WCF服务创建与抛出强类型SOAP Fault
原创地址:http://www.cnblogs.com/jfzhu/p/4060666.html 转载请注明出处 前面的文章<WCF服务的异常消息>中介绍过,如果WCF Service发生 ...
随机推荐
- css之操作属性
1.文本 1.文本颜色:color 颜色属性被用来设置文字的颜色. 颜色是通过CSS最经常的指定: 十六进制值 - 如: #FF0000 一个RGB值 - 如: RGB(255,0,0) 颜色的名称 ...
- 【python】正则替换
正则替换可以使用函数 例如:替换字符串中所有#1.2.3.4#格式中的数字为0 import re def replace(x): def _replace(matched): m = matched ...
- HTML&javaSkcript&CSS&jQuery&ajax(五)
一.Framset标签定义了每个框架中的HTML文档, 1. <framset cols="25%,75%"> <frame src="frame_a. ...
- day4-list,列表
dist: 增:1.append(obj),在列表最后添加元素: 2.insert(index,object),在索引处添加元素: 3.extend,迭代添加元素,所添加元素必须可迭代. 删:1.po ...
- python截图
import time import os, win32gui, win32ui, win32con, win32api def window_capture(dpath,name,srcbmp=[0 ...
- python 之 列表与字典
1.4 列表与字典 列表与字典,这两种类型,都是各种类型的集合,以列表为例,如果列表中包含列表,就形成嵌套. 这两种类型几乎是所有python脚本的主要工作组件 . 这种结构信息是可变的可修改的.不像 ...
- Just oj 2018 C语言程序设计竞赛(高级组)D: 四边形面积
D: 四边形面积 时间限制: 1 s 内存限制: 128 MB 提交 我的状态 题目描述 有一个四边形,现在需要求它的面积 输入 输入四行,每行两个数整数xx, yy (1≤x,y ...
- Oracle查询CLOB字段类型的内容
select dbms_lob.substr(lo.ldtext) as text from longdescription lo
- 去掉A标签的点击选中边框
非IE a:focus { outline:none; }
- hadoop集群运行jps命令以后Datanode节点未启动的解决办法
出现该问题的原因:在第一次格式化dfs后,启动并使用了hadoop,后来又重新执行了格式化命令(hdfs namenode -format),这时namenode的clusterID会重新生成,而da ...