简体   繁体   English

PHP中的SOAP和WSDL Web服务

[英]SOAP and WSDL Webservice in PHP

I am trying to create a simple web-service with SOAP and WSDL. 我正在尝试使用SOAP和WSDL创建一个简单的Web服务。 I use the built in Soap-server for the handling. 我使用内置的Soap服务器进行处理。 When i try to run the web-service i get this error: 当我尝试运行Web服务时,出现此错误:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'E:\\xampp\\htdocs\\PHPWebService\\blog.wsdl' : Start tag expected, '<' not found SOAP错误:解析WSDL:无法从'E:\\ xampp \\ htdocs \\ PHPWebService \\ blog.wsdl'加载:预期开始标记,找不到'<'

I have tried putting the Soap-server code in the begin of the code and on the end to see if that resulted in something but it doesn't. 我试过将Soap-server代码放在代码的开头,然后放在结尾,以查看是否产生了某些结果,但没有。

Here is my code: 这是我的代码:

<?php



    class TestClass{
        public function getVar($var){
            return "Value of var = " + $var;
        }
    }

    $oServer = new SoapServer("blog.wsdl");
    $oServer->setClass("TestClass");
    $oServer->handle();

?>

I used a RESTful webservice now. 我现在使用了RESTful Web服务。 So this question doesnt have to be answered no more. 因此,不必再回答这个问题了。 What i did is i used jakesankey's webservice: https://github.com/jakesankey/PHP-RestServer-Class and run this simple code: 我所做的是我使用了jakesankey的web服务: https : //github.com/jakesankey/PHP-RestServer-Class并运行以下简单代码:

I hope anyone find this usefull 希望任何人都觉得有用

   <?php
 require_once "RestServer.php";

 class Hello
 {
   public function sayHello($name, $poop)
   {
      // RestServer will encode return objects as JSON
      return array("Response" => "Hello, " . $name . " and dont forget ".$poop);
   }
 }

 $hello = new Hello();
 $rest = new RestServer($hello);
 $rest->handle();

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM