dtnpf35197 2013-01-24 16:14
浏览 155
已采纳

SoapClient PHP返回错误

I am tying to get a simple SOAP call to work in php, but I have no clue what is wrong. It is my first time using soap so please be gentle :)

when I make a manual call like this, it all workes

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
  <tem:AuthenticationHeader>
     <!--Optional:-->
     <tem:UserName>****</tem:UserName>
     <!--Optional:-->
     <tem:Password>***</tem:Password>
  </tem:AuthenticationHeader>
</soapenv:Header>
<soapenv:Body>
 <tem:SignUp>
     <!--Optional:-->
     <tem:email>test@test.se</tem:email>
     <!--Optional:-->
     <tem:password>password</tem:password>
  </tem:SignUp>
</soapenv:Body>
</soapenv:Envelope>

But when i do it in php, i get " Function ("SignUp") is not a valid method for this service"

try {
    $soap_client = new SoapClient("http://url.com/Service.asmx?WSDL");
    $soapHeader = array('UserName' => '*****','Password' => '***');
    // Soap Header initialization
    $header = new SOAPHeader('http://tempuri.org/', 'AuthenticationHeader', $soapHeader);        
    // add the Header to the Soap Client before request
    $soap_client->__setSoapHeaders($header); 
    $args  = array('email'=>'tetsing@pp.se','password' =>'tetsing');
    $user = $soap_client->SignUp($args);
    print_r($user);

} catch (Exception $e) {
    print_r($e);
}

edit1: Added WSDL

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
    <s:element name="AuthenticationHeader" type="tns:AuthenticationHeader"/>
    <s:complexType name="AuthenticationHeader">...</s:complexType>
    <s:element name="SignUp">
      <s:complexType>
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="email" type="s:string"/>
          <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
        </s:sequence>
      </s:complexType>
     </s:element>

Edit 2:

Edit 3: getFunctions gives med

    array(18) {
  [0]=>
  string(80) "GetGameProgressDataResponse GetGameProgressData(GetGameProgressData $parameters)"
  [1]=>
  string(101) "GetGameParticipantPicturesResponse GetGameParticipantPictures(GetGameParticipantPictures $parameters)"
  [2]=>
  string(41) "SignUpResponse SignUp(SignUp $parameters)"
  [3]=>
  string(38) "LoginResponse Login(Login $parameters)"
  [4]=>
  string(53) "CreateGameResponse CreateGame(CreateGame $parameters)"
  [5]=>
  string(62) "GetActivitiesResponse GetActivities(GetActivities $parameters)"
  [6]=>
  string(62) "SetActivitiesResponse SetActivities(SetActivities $parameters)"
  [7]=>
  string(68) "GetParticipantsResponse GetParticipants(GetParticipants $parameters)"
  [8]=>
  string(68) "SetParticipantsResponse SetParticipants(SetParticipants $parameters)"
  [9]=>
  string(80) "GetGameProgressDataResponse GetGameProgressData(GetGameProgressData $parameters)"
  [10]=>
  string(101) "GetGameParticipantPicturesResponse GetGameParticipantPictures(GetGameParticipantPictures $parameters)"
  [11]=>
  string(41) "SignUpResponse SignUp(SignUp $parameters)"
  [12]=>
  string(38) "LoginResponse Login(Login $parameters)"
  [13]=>
  string(53) "CreateGameResponse CreateGame(CreateGame $parameters)"
  [14]=>
  string(62) "GetActivitiesResponse GetActivities(GetActivities $parameters)"
  [15]=>
  string(62) "SetActivitiesResponse SetActivities(SetActivities $parameters)"
  [16]=>
  string(68) "GetParticipantsResponse GetParticipants(GetParticipants $parameters)"
  [17]=>
  string(68) "SetParticipantsResponse SetParticipants(SetParticipants $parameters)"
}
  • 写回答

1条回答 默认 最新

  • dongzhiyong8577 2013-01-26 12:37
    关注

    The code was fine, it was a server problem, and they fixed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。