致命错误:未捕获的SoapFault异常:[SOAP-ENV:Client]在此服务的WSDL中未定义“操作”

时间:2014-01-03 06:32:15

标签: 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的Web服务,当我改变时出现以下错误:

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

1 个答案:

答案 0 :(得分:2)

 $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

<强>编辑:

现在问题在于您的请求消息结构。该内容字段在消息下。顺便说一下,你的最终肥皂要求应该是这样的,

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

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

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

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

echo $exception;      

}