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

WBOY
Libérer: 2016-06-13 13:51:35
original
789 Les gens l'ont consulté

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;
}

------解决方案--------------------

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!