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发生 ...
随机推荐
- linux 下安装vscode
下载安装包 https://code.visualstudio.com/docs/?dv=linux64_deb (注意是deb包) sudo dpkg -i code_1.18.1-15108573 ...
- gnuradio 初次使用
参考链接: 入门 http://www.cnblogs.com/moon1992/p/5739027.html 创建模块 http://www.cnblogs.com/moon1992/p/54246 ...
- Saruman's Army(POJ3069)
Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. ...
- laravel 注入那点事
public function delete(Group $groupId, Post $postId) { $postId->delete(); return response()->j ...
- laravel 路由缓存
使用路由缓存之前,需要知晓路由缓存只能用于控制器路由,不能用于闭包路由,如果路由定义中包含闭包路由将无法进行路由缓存,只有将所有路由定义转化为控制器路由或资源路由后才能执行路由缓存命令: php ar ...
- vue 中样式的绑定
1.class的对象绑定 //对应的css <style> .active { color: red; } </style> <!--html 对应的代码--> & ...
- jenkins持续集成:jenkins+SVN
实现jenkins从svn拉取最新的代码,再执行驱动脚本进行自动化测试 新建一个任务 输入任务名,选“构建一个自由风格的软件项目”,点左下角“确定” 丢弃旧的构建,如下设置为保留3天内的10条构建记录 ...
- C和Java判断一个数字是否为素数
C: /* 素数: 素数又称质数.所谓素数是指除了 1 和它本身以外,不能被任何整数整除的数,例如17就是素数,因为它不能被 2~16 的任一整数整除. */ # include <stdio. ...
- svn_linux + apache 实现网页访问svn
CentOS7:搭建SVN + Apache 服务器实现网页访问 1. 安装httpd 安装httpd服务: $ sudo yum install httpd 检查httpd是否安装成功: $ htt ...
- 目标检测算法之R-CNN算法详解
R-CNN全称为Region-CNN,它可以说是第一个成功地将深度学习应用到目标检测上的算法.后面提到的Fast R-CNN.Faster R-CNN全部都是建立在R-CNN的基础上的. 传统目标检测 ...