代码摘要:   
  服务端(C#):   
  [WebService(Namespace="www.ah165.com")]   
  public   class   Service1   :   System.Web.Services.WebService   
  {   
  public   Service1(){ InitializeComponent();}   
  [WebMethod]   
  public   string   JouweiTest2(string   hehe)   
  {   
  return   "<"+hehe+">";   
  }}   
      客户端(php):   
  require('nusoap.php');   
  $s=new   soapclient('http://localhost/WebServiceTest/Service1.asmx',true);   
  $s->soap_defencoding   =   'UTF-8';   
  $result=$s->call('JouweiTest2',   array('hehe'   =>   '你好'),"www.ah165.com","www.ah165.com/JouweiTest2");   
  if   (!$err=$s->getError())   {   
  echo   '结果:   '.$result;     
  }   else   {   
  echo   '错误:   '.$err;   
  }   
  echo   "<xmp>".$s->request."</xmp><br><br>";   
  echo   "<xmp>".$s->response."</xmp>";   
    
  执行结果:   
  结果:   <>   
  POST   /WebServiceTest/Service1.asmx   HTTP/1.0   
  Host:   localhost   
  User-Agent:   NuSOAP/0.7.2   (1.95)   
  Content-Type:   text/xml;   charset=UTF-8   
  SOAPAction:   "www.ah165.com/JouweiTest2"   
  Content-Length:   502   
    
  <?xml   version="1.0"   encoding="UTF-8"?>
<SOAP-ENV:Envelope   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:xsd="http://www.w3.org/2001/XMLSchema"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns5838:JouweiTest2   xmlns:ns5838="www.ah165.com">
<hehe   xsi:type="xsd:string">wbxan</hehe>
</ns5838:JouweiTest2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>   
    
    
    
  HTTP/1.1   200   OK   
  Server:   Microsoft-IIS/5.0   
  Date:   Thu,   09   Feb   2006   02:58:06   GMT   
  X-Powered-By:   ASP.NET   
  X-AspNet-Version:   1.1.4322   
  Cache-Control:   private,   max-age=0   
  Content-Type:   text/xml;   charset=utf-8   
  Content-Length:   358   
    
  <?xml   version="1.0"   encoding="utf-8"?>
<soap:Envelope   xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<JouweiTest2Response   xmlns="www.ah165.com">
<JouweiTest2Result>&lt;&gt;</JouweiTest2Result>
</JouweiTest2Response>
</soap:Body>
</soap:Envelope>   
    
  -------------------------------   
  从上面的代码可以看出,服务器端接受到的参数hehe的值为空。   
  高手能解释一下问题出在那里吗?谢谢!

解决方案 »

  1.   

    没试过,但据了解!不同系统间web服务可能会有差别!可严格测试一下传参的数据!理论上,它们都要变成xml的数据类型!不同的语言在转成xml的数据类型时可能会差别!其他的,看你传参方式对不对!
      

  2.   

    我无论用rpc 还是 document 都无法将参数传递过去...
      

  3.   

    调用.net服务端webservice,方法有所不同。。$proxy = $client->getProxy();
    $result = $proxy->JouweiTest2($params);
      

  4.   


    我用getProxy 卻找不到方法.
    似乎還有命名空間的問題
      

  5.   

    require_once('../nusoap/lib/nusoap.php');
    $client = new soapclient('http://tia.gncc.net/ws/hrmanager.asmx?WSDL', 'wsdl');   

    $client->soap_defencoding = 'utf-8';
    $client->decode_utf8 = false;
    $client->setDefaultRpcParams(true);
    $params = array(
    'account'   => $loginid
        
    );
    $proxy = $client->getProxy();
    $result = $proxy->GetUserInfoByAccount($params);
            $document=$proxy->document;  
    echo $document;
      

  6.   

    我也是,PHP 调用Java 无法出参数,不知道啥原因,楼主解决了吗?