php怎么调用.net的webservice?100分送上

WBOY
发布: 2016-06-13 13:51:35
原创
818 人浏览过

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.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板