php怎么调用.net的webservice?100分送上
程序员文章站
2024-01-19 11:24:04
...
php如何调用.net的webservice???100分送上
php如何调用.net的webservice?请高手赐教,我写了一面一段程序,可是总是提示错误:没有创建实例对象,大家帮我看一下,哪里错了?
客户端php程序:
require('./require/nusoap/lib/nusoap.php');
$userinfo=array('username' => 'fiekscos');
$s=new soapclient('http://www.yy-sports.com/webservice/memberinfo.asmx?WSDL');
$s->soap_defencoding = 'UTF-8';
$s->decode_utf8 = false;
$result = $s->__soapCall('ValidUserLoginName',array('UserLoginName' => $userinfo));
echo $result;
?>
服务器端.net的webservice程序:
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using com.Basic;
///
///MemberInfo 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class MemberInfo : System.Web.Services.WebService
{
//
/// SOAP认证类
///
public SecurityHeader CurrentUser
{
get { return _CurrentUser; }
set { _CurrentUser = value; }
}
private SecurityHeader _CurrentUser;
public MemberInfo()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
private bool ValidateUser(string user, string pass)
{
Boolean reVal=false;
EDbOperator oo = new EDbOperator();
try
{
String sql = "Select Count([ID]) From WebService_User Where [Name]='{0}' And Pass='{1}' And [Status] = 1";
user = Tools.FilterSQL(user.Trim());
pass = Tools.FilterSQL(pass.Trim());
sql = String.Format(sql, user, pass);
Int32 Count = Convert.ToInt32(oo.DbOperator.ExecScalar(sql));
if (Count > 0)
{
reVal = true;
}
}
finally
{
oo.Dispose();
}
return reVal;
}
///
/// 根据系列代码,返回系列名称
///
/// 系列代码
///系列名称
[WebMethod(Description = "输入一个新的用户登录名称,判断是否已经注册 0为未注册 非0为已注册或出错"), SoapHeader("CurrentUser")]
public Int32 ValidUserLoginName(String UserLoginName)
{
if (!ValidateUser(CurrentUser.UserName, CurrentUser.UserPass)) { throw new Exception("出错"); }
Int32 reVal = 1;
EDbOperator oo = new EDbOperator();
try
{
String sql;
sql = "Select Count([ID]) From YY_User Where [UserName] = '" + UserLoginName + "'";
reVal = Convert.ToInt32(oo.DbOperator.ExecScalar(sql));
}
finally
{
oo.Dispose();
}
return reVal;
}
}
//自定义Soap Header Class
public class SecurityHeader : System.Web.Services.Protocols.SoapHeader
{
public String UserName;
public String UserPass;
}
------解决方案--------------------
php如何调用.net的webservice?请高手赐教,我写了一面一段程序,可是总是提示错误:没有创建实例对象,大家帮我看一下,哪里错了?
客户端php程序:
require('./require/nusoap/lib/nusoap.php');
$userinfo=array('username' => 'fiekscos');
$s=new soapclient('http://www.yy-sports.com/webservice/memberinfo.asmx?WSDL');
$s->soap_defencoding = 'UTF-8';
$s->decode_utf8 = false;
$result = $s->__soapCall('ValidUserLoginName',array('UserLoginName' => $userinfo));
echo $result;
?>
服务器端.net的webservice程序:
using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using com.Basic;
///
///MemberInfo 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class MemberInfo : System.Web.Services.WebService
{
//
/// SOAP认证类
///
public SecurityHeader CurrentUser
{
get { return _CurrentUser; }
set { _CurrentUser = value; }
}
private SecurityHeader _CurrentUser;
public MemberInfo()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
private bool ValidateUser(string user, string pass)
{
Boolean reVal=false;
EDbOperator oo = new EDbOperator();
try
{
String sql = "Select Count([ID]) From WebService_User Where [Name]='{0}' And Pass='{1}' And [Status] = 1";
user = Tools.FilterSQL(user.Trim());
pass = Tools.FilterSQL(pass.Trim());
sql = String.Format(sql, user, pass);
Int32 Count = Convert.ToInt32(oo.DbOperator.ExecScalar(sql));
if (Count > 0)
{
reVal = true;
}
}
finally
{
oo.Dispose();
}
return reVal;
}
///
/// 根据系列代码,返回系列名称
///
/// 系列代码
///
[WebMethod(Description = "输入一个新的用户登录名称,判断是否已经注册 0为未注册 非0为已注册或出错"), SoapHeader("CurrentUser")]
public Int32 ValidUserLoginName(String UserLoginName)
{
if (!ValidateUser(CurrentUser.UserName, CurrentUser.UserPass)) { throw new Exception("出错"); }
Int32 reVal = 1;
EDbOperator oo = new EDbOperator();
try
{
String sql;
sql = "Select Count([ID]) From YY_User Where [UserName] = '" + UserLoginName + "'";
reVal = Convert.ToInt32(oo.DbOperator.ExecScalar(sql));
}
finally
{
oo.Dispose();
}
return reVal;
}
}
//自定义Soap Header Class
public class SecurityHeader : System.Web.Services.Protocols.SoapHeader
{
public String UserName;
public String UserPass;
}
------解决方案--------------------
相关文章
相关视频
上一篇: 您的PHP似乎没有安装运行WordPress所必需的MySQL扩展。
下一篇: PHP daemon
推荐阅读
-
php怎么调用.net的webservice?100分送上
-
php如何调用 .net开发的 webservice
-
PHP使用SOAP调用.net的WebService问题
-
求高人指点.net开发的webservice调用外部php写的webservice
-
PHP使用SOAP调用.net的WebService数据_PHP
-
PHP中调用ASP.NET的WebService的代码
-
PHP调用.NET的WebService 简单实例
-
PHP使用SOAP调用.net的WebService数据
-
php怎么采集或者 调用 .net开发的 webservice
-
php 调用c# .NET 写的webservice(亲测通过)