php - fatal error : Uncaught SoapFault exception: [SOAP-ENV:Client] Operation '' is not defined in the WSDL for this service

标签 php web-services soap wsdl

我有一个 wsdl http://soap.m4u.com.au/?wsdl

需要调用“sendMessages”方法,但我每次都会收到以下错误。

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Operation '' is not defined in the WSDL for this service

我的客户端文件代码是:

$client = new SoapClient("http://soap.m4u.com.au/?wsdl", array("trace" => 1, "soap_version" => SOAP_1_2));
$params = array(
      "authentication" => array(
        "userId" => "******",
        "password" => "********"
      ),
      "requestBody" => array(
        "messages" => array(
            "message" => array(
                "sequenceNumber"=>"1",
                "recipients" => array(
                    "recipient" => array(
                        "999966663333"
                    )
                ),
                "content" => "Message Content"
            )
        )
      )

);  

$response = $client->__soapCall("sendMessages", array($params));

更新 这个网络服务使用 SOAP 1.1 而不是 SOAP 1.2,当我更改时,出现以下错误:

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] The request is either not well-formed or is not valid against the relevant schema.

最佳答案

 $client = new SoapClient("http://soap.m4u.com.au/?wsdl", array("trace" => 1, "soap_version" => SOAP_1_1));

替换此行,

更正:“soap_version”=>SOAP_1_1

此服务使用 SOAP 1.1,而不是 SOAP 1.2

已编辑:

现在问题出在您的请求消息结构中。该内容字段位于消息下方。顺便说一句,你的最终 SOAP 请求应该是这样的,

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:ns="http://xml.m4u.com.au/2009">
 <soapenv:Header/>
 <soapenv:Body>
  <ns:sendMessages>
     <ns:authentication>
        <ns:userId>?</ns:userId>
        <ns:password>?</ns:password>
     </ns:authentication>
     <ns:requestBody>
        <ns:messages sendMode="normal">
           <!--1 or more repetitions:-->
           <ns:message format="SMS" sequenceNumber="0">
              <!--You may enter the following 7 items in any order-->
              <!--Optional:-->
              <ns:origin>?</ns:origin>
              <ns:recipients>
                 <!--1 or more repetitions:-->
                 <ns:recipient uid="0">?</ns:recipient>
              </ns:recipients>
              <ns:content>?</ns:content>
              <!--Optional:-->
              <ns:scheduled>?</ns:scheduled>
              <!--Optional:-->
              <ns:deliveryReport>false</ns:deliveryReport>
              <!--Optional:-->
              <ns:validityPeriod>169</ns:validityPeriod>
              <!--Optional:-->
              <ns:tags>
                 <!--1 or more repetitions:-->
                 <ns:tag name="?">?</ns:tag>
              </ns:tags>
           </ns:message>
        </ns:messages>
     </ns:requestBody>
  </ns:sendMessages>
    </soapenv:Body>
 </soapenv:Envelope>

您可以忽略上述请求中的可选字段。仅供引用..我是从soap ui 生成的。让我知道您的进一步问题。

还有一件事,如果您将客户端 SOAP 调用包装在 try block 中并在代码中捕获它,您将不会得到这些未处理的异常,例如:

try{
       $response = $client->__soapCall("sendMessages", array($params));           
   }
catch (SoapFault $exception) {

echo $exception;      

}

关于php - fatal error : Uncaught SoapFault exception: [SOAP-ENV:Client] Operation '' is not defined in the WSDL for this service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20897968/

相关文章:

c# - VS2008 - 从 Web 服务反序列化时出错

java - 没有wsdl的apache cxf客户端

php - Visual Studio PHP

php - 显示 mysql 表中的特定数据

web-services - IIS7 中 Web 应用程序文件夹的 IP 限制

java - 如何使用 oAuth 验证 Restful Web 服务

SQL 数据上的 PHP 数学

php - 哪个先发生 : init or preDispatch?

c# - 从 ASP.NET WebAPI 应用程序调用 Web 服务

php - 重定向到在 Laravel 5 中不起作用的路由