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发生 ...
随机推荐
- day06 数字类型,字符串类型,列表类型
一:整型int# ======================================基本使用======================================# 1.用途:记录年龄 ...
- LeetCode(74):搜索二维矩阵
Medium! 题目描述: 编写一个高效的算法来判断 m x n 矩阵中,是否存在一个目标值.该矩阵具有如下特性: 每行中的整数从左到右按升序排列. 每行的第一个整数大于前一行的最后一个整数. 示例 ...
- 使用Navicat快速生成数据库字典
https://blog.csdn.net/maquealone/article/details/60764420
- HTML&javaSkcript&CSS&jQuery&ajax(二)
一.HTML 1.标签<a href="http:www.baidu.com">This is a link </a> <img sr ...
- Allegro PCB Design GXL (legacy) 由零散的对象构成一个Shape
Allegro PCB Design GXL (legacy) version 16.6-2015 从DXF文件中导入板框之后,发现板框是由Line Segment.Arc Segment等对象组成, ...
- python多线程爬取-今日头条的街拍数据(附源码加思路注释)
这里用的是json+re+requests+beautifulsoup+多线程 1 import json import re from multiprocessing.pool import Poo ...
- python 装饰器--对有无参数的函数进行装饰
# 使用装饰器无参数的函数进行装饰# def func(funcionName): # print('-----1------') # def func_in(): # print('--func_i ...
- Vue-切割json数组字符串并循环输出
Json "detailList":[ " 04/08/2016 - LA - - Dept. - TITLE (Lien Reported)", " ...
- pkusc2018数学题
题解: 还是很水的 复制个题面过来 好吧我不会复制 https://www.cnblogs.com/skylee03/p/9127130.html 题目链接 第一题是个傻逼题 初中数学题随便凑凑 ( ...
- [转]解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
来源:http://www.cnblogs.com/sprinng/p/5141233.html 1.添加M2_HOME的环境变量 2.Preference->Java->Installe ...