今天用curl模拟调用 各种出错
接口请求格式是这样的
POST /Web/Web.asmx HTTP/1.1
Host: 121.14.195.138
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SendSMS"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendSMS xmlns="http://tempuri.org/">
<UserName>string</UserName>
<UserPwd>string</UserPwd>
<Mobile>string</Mobile>
<Message>string</Message>
</SendSMS>
</soap:Body>
</soap:Envelope>
用curl模拟出错 就不在描述了;
然后在论坛发现可以用soapclient可以很方便的解决这样websever
百度了下 发现一个很不错的例子:
<?php
header ( "Content-Type: text/html; charset=gb2312" );
/*
* 指定WebService路径并初始化一个WebService客户端
*/
$ws = "http://www.webservicex.net/globalweather.asmx?wsdl";//webservice服务的地址
$client = new SoapClient ($ws);
/*
* 获取SoapClient对象引用的服务所提供的所有方法
*/
echo ("SOAP服务器提供的开放函数:");
echo ('<pre>');
var_dump ( $client->__getFunctions () );//获取服务器上提供的方法
echo ('</pre>');
echo ("SOAP服务器提供的Type:");
echo ('<pre>');
var_dump ( $client->__getTypes () );//获取服务器上数据类型
echo ('</pre>');
echo ("执行GetGUIDNode的结果:");
$result=$client->getWeather(array('CityName'=>'zhengzhou','CountryName'=>'china'));//查询中国郑州的天气,返回的是一个结构体
echo $result->GetWeatherResult;//显示结果
?>
$params = array(
'UserName' =>$username,
'UserPwd' => $password,
'Mobile'=> $mobile,
'Message'=>$content
);
$client = new SoapClient("http://xx:8006/Web/Web.asmx?wsdl");
$result=$client->SendSMS($params);
echo $result->SendSMSResult;//显示结果