【问题标题】:PHP SOAP doesn't catch SAP PI/XI SOAP faultPHP SOAP 没有捕获 SAP PI/XI SOAP 错误
【发布时间】:2011-12-15 13:50:40
【问题描述】:

我向 SAP PI Web 服务发出 SOAP 请求。该服务返回这样的 SOAP 错误:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP:Body>
          <SOAP:Fault>
             <faultcode>SOAP:Server</faultcode>
             <faultstring>Server Error</faultstring>
             <detail>
                <s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0">
                   <context>XIAdapter</context>
                   <code>ADAPTER.JAVA_EXCEPTION</code>
                   <text>com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn't retrieve binding for the given channelId: Binding:CID=null;
        at com.sap.aii.af.service.cpa.impl.lookup.AbstractLookupManager.getBindingByChannelId(AbstractLookupManager.java:173)
        at com.sap.aii.adapter.soap.web.MessageServlet.doPost(MessageServlet.java:449)
        ....
        at com.sap.engine.core.thread.execution.CentralExecutor$SingleThread.run(CentralExecutor.java:327)</text>
                </s:SystemError>
             </detail>
          </SOAP:Fault>
       </SOAP:Body>
</SOAP:Envelope>

在 PHP 中我确实遵循:

$client = new SoapClient('path/to/wsdl', array(
            'cache_wsdl' => WSDL_CACHE_NONE,
            'exceptions' => true,
            'login' => 'some_login',
            'password' => 'some_password',
        ));
$result = $client->some_funtion("bla-bla-bla");
var_dump($result);

它打印 null,但应该抛出异常

如果我在自己的 Web 服务中输出相同的 xml(soap 错误),我可以捕捉到它。

【问题讨论】:

    标签: php soap sap sap-xi sap-pi


    【解决方案1】:

    问题出在 WSDL 中的 output 标记中。我添加了这个标签,它解决了我的问题

    <wsdl:portType name="...">
         <wsdl:operation name="...">
             ...
             <wsdl:input message="..."/>
             <wsdl:output message="..."/> <!--- that tag-->
         </wsdl:operation>
    </wsdl:portType>
    

    【讨论】:

      【解决方案2】:

      那是因为你没有 try/catch 块。

      试试这个:

      $client = new SoapClient('path/to/wsdl', array(
                  'cache_wsdl' => WSDL_CACHE_NONE,
                  'exceptions' => true,
                  'login' => 'some_login',
                  'password' => 'some_password',
              ));
      
      try{
        $result = $client->some_funtion("bla-bla-bla");
      } catch (SoapFault $e){
         exit('caught soap fault');
      }
      

      【讨论】:

      • 不,这不是问题的原因。尝试/捕捉没有帮助。异常应该抛出 php soap 客户端,但它不会发生
      猜你喜欢
      • 1970-01-01
      • 2018-04-19
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多