PHP - 创建和调用 SOAP Web 服务 - 错误 [英] PHP - create and call SOAP web service - error

查看:26
本文介绍了PHP - 创建和调用 SOAP Web 服务 - 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我尝试通过 wsdl 调用我的网络服务时,我都会收到此处显示的错误消息.我认为这可能是 WSDL 定义中的一个问题,因为我不确定我在 WSDL 定义中要做什么:

 [22-Sep-2011 18:54:46] PHP 致命错误:未捕获的 SoapFault 异常:[HTTP] 在/www/zendserver/htdocs/dev/csc/request.php:4 中找不到堆栈跟踪:#0 [内部函数]:SoapClient->__doRequest('__call('EchoText', Array)#2/www/zendserver/htdocs/dev/csc/request.php(4):SoapClient->EchoText('test')#3 {main} 扔在/www/zendserver/htdocs/dev/csc/request.php 上4号线

<小时>

我有一个非常简单的网络服务,位于:http://192.168.1.2:10088/csc/csc.php

 "http://192.168.1.2:10088/csc/csc.php"));$server->addFunction('EchoText');$server->handle();?>

<小时>

我有一个接口页面,这是我访问的页面,然后出现上面显示的错误,位于:http://192.168.1.2:10088/csc/request.php

EchoText("test");回声 $result;>?

<小时>

我有我的 WSDL,位于:http://192.168.1.2:10088/csc/NewWSDLFile.wsdl

<wsdl:类型><xsd:schema targetNamespace="http://192.168.1.2:10088/csc/NewWSDLFile.wsdl"><xsd:element name="EchoText"><xsd:complexType><xsd:序列><xsd:element name="in" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="EchoTextResponse"><xsd:complexType><xsd:序列><xsd:element name="out" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema></wsdl:types><wsdl:message name="EchoTextRequest"><wsdl:part element="tns:EchoText" name="参数"/></wsdl:message><wsdl:message name="EchoTextResponse"><wsdl:part element="tns:EchoText" name="参数"/></wsdl:message><wsdl:portType name="NewWSDLFile"><wsdl:operation name="EchoText"><wsdl:input message="tns:EchoTextRequest"/><wsdl:output message="tns:EchoTextResponse"/></wsdl:操作></wsdl:portType><wsdl:binding name="NewWSDLFileSOAP" type="tns:NewWSDLFile"><soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="EchoText"><soap:operation soapAction="http://192.168.1.2:10088/csc/NewWSDLFile/EchoText"/><wsdl:输入><soap:body use="literal"/></wsdl:input><wsdl:输出><soap:body use="literal"/></wsdl:output></wsdl:操作></wsdl:binding><wsdl:service name="NewWSDLFile"><wsdl:port binding="tns:NewWSDLFileSOAP" name="NewWSDLFileSOAP"><soap:address location="http://192.168.1.2:10088/csc/csc.php"/></wsdl:port></wsdl:service></wsdl:定义>

<小时>

更新..

通过执行 try catch 和 print_r($e),我能够获得有关错误消息的更多详细信息;...这里是详细的错误消息:

<预><代码>SoapFault 对象 ([消息:受保护] => 未找到[字符串:私人] =>[代码:受保护] => 0[文件:受保护] =>/www/zendserver/htdocs/dev/csc/request.php[行:受保护] => 7[trace:private] => 数组 ([0] => 数组 ([功能] => __doRequest[类] => SoapClient[类型] => ->[参数] => 数组 ([0] =>[1] => http://192.168.1.2:10088/csc/csc.wsdl[2] => http://www.example.org/NewWSDLFile/EchoText[3] => 1[4] => 0))[1] => 数组 ([功能] => __call[类] => SoapClient[类型] => ->[参数] => 数组 ([0] => 回声文本[1] => 数组 ([0] => 测试)))[2] => 数组 ([文件] =>/www/zendserver/htdocs/dev/csc/request.php[行] => 7[功能] => 回声文本[类] => SoapClient[类型] => ->[参数] => 数组 ([0] => 测试)))[故障字符串] => 未找到[故障代码] => HTTP)

解决方案

SoapFault => Not Found 是 SoapClient 无法访问服务器.

192.168.1.2 是本地 IP 地址,Web 服务器是否也在本地网络上?否则这就是您的客户不工作的原因.

Every time i try to make a call to my webservice, through the wsdl, i get the error message shown here. I think its probably an issue within the the WSDL defintion, because I am not really sure what i am doing within the WSDL definition to begin with:

 [22-Sep-2011 18:54:46] PHP Fatal error:  Uncaught SoapFault exception:
 [HTTP] Not Found in /www/zendserver/htdocs/dev/csc/request.php:4
 Stack trace:
 #0 [internal function]: SoapClient->__doRequest('<?xml version="...',
 'http://192.168....', 'http://www.exam...', 1, 0)
 #1 [internal function]: SoapClient->__call('EchoText', Array)
 #2 /www/zendserver/htdocs/dev/csc/request.php(4):
 SoapClient->EchoText('test')
 #3 {main}   thrown in /www/zendserver/htdocs/dev/csc/request.php on
 line 4


I have a very simple web service, located at: http://192.168.1.2:10088/csc/csc.php

<?php

function EchoText($text){
    return "ECHO: ".$text;
}

$server = new SoapServer(null,
                         array('uri' => "http://192.168.1.2:10088/csc/csc.php"));
$server->addFunction('EchoText');
$server->handle();

?>


I have an interfacing page, which is what i access and then get the error shown above, located at: http://192.168.1.2:10088/csc/request.php

<?php
$client = new SoapClient("http://192.168.1.2:10088/csc/NewWSDLFile.wsdl");

$result = $client->EchoText("test");
echo $result;
>?


I have my WSDL, located at: http://192.168.1.2:10088/csc/NewWSDLFile.wsdl

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://192.168.1.2:10088/csc/NewWSDLFile.wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NewWSDLFile" targetNamespace="http://192.168.1.2:10088/csc/NewWSDLFile.wsdl">
  <wsdl:types>
    <xsd:schema targetNamespace="http://192.168.1.2:10088/csc/NewWSDLFile.wsdl">
      <xsd:element name="EchoText">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="in" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="EchoTextResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="out" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="EchoTextRequest">
    <wsdl:part element="tns:EchoText" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="EchoTextResponse">
    <wsdl:part element="tns:EchoText" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="NewWSDLFile">
    <wsdl:operation name="EchoText">
      <wsdl:input message="tns:EchoTextRequest"/>
      <wsdl:output message="tns:EchoTextResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="NewWSDLFileSOAP" type="tns:NewWSDLFile">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="EchoText">
      <soap:operation soapAction="http://192.168.1.2:10088/csc/NewWSDLFile/EchoText"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="NewWSDLFile">
    <wsdl:port binding="tns:NewWSDLFileSOAP" name="NewWSDLFileSOAP">
      <soap:address location="http://192.168.1.2:10088/csc/csc.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


UPDATE..

I was able to get more detailed information on the error message by doing a try catch and print_r($e);... here is the detailed error message:


SoapFault Object (
  [message:protected] => Not Found
  [string:private] =>
  [code:protected] => 0
  [file:protected] => /www/zendserver/htdocs/dev/csc/request.php
  [line:protected] => 7
  [trace:private] => Array ( 
    [0] => Array (
      [function] => __doRequest
      [class] => SoapClient
      [type] => ->
      [args] => Array (
         [0] =>
         [1] => http://192.168.1.2:10088/csc/csc.wsdl
         [2] => http://www.example.org/NewWSDLFile/EchoText
         [3] => 1
         [4] => 0
      )
    )
   [1] => Array (
      [function] => __call
      [class] => SoapClient
      [type] => ->
      [args] => Array (
         [0] => EchoText
         [1] => Array (
             [0] => test
         )
      )
    )
   [2] => Array (
      [file] => /www/zendserver/htdocs/dev/csc/request.php
      [line] => 7
      [function] => EchoText
      [class] => SoapClient
      [type] => ->
      [args] => Array ( 
         [0] => test
      )
    )
  )
  [faultstring] => Not Found
  [faultcode] => HTTP
) 

解决方案

SoapFault => Not Found is that the SoapClient can't reach the server.

192.168.1.2 is a local IP-address, is the web server also on the local network? Otherwise that is the reason why your client isn't working.

这篇关于PHP - 创建和调用 SOAP Web 服务 - 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆