dryk50495 2013-08-31 13:42
浏览 30
已采纳

too long

I am developing a soap webservice using zend_soap_server. I use Zend_Soap_AutoDiscover to auto generate wsdl of my webservice.

Here is the code

public function indexAction() { // my websrvice method

      $server = new Zend_Soap_Server("admin/webservice/wsdl");

      $server->setEncoding('UTF-8');

      $server->setClass('Webservice');

      $server->handle();
}

public function wsdlAction() { // my wsdl method

      $wsdl = new Zend_Soap_AutoDiscover();

      $wsdl->setClass('Webservice');

      $wsdl->setUri("/admin/webservice");

      $wsdl->handle();
}

My problem is that when i view the source of generated wsdl the first line is:

<?xml version="1.0"?>

But i want the encoding in the xml tag:

<?xml version="1.0" encoding="UTF-8"?>

What should i do to get this?

Thx in advance.

  • 写回答

1条回答 默认 最新

  • douquan1015 2013-09-05 05:15
    关注

    I checked the Zend Framework code and it would appear that the first line of the WSDL is hard-coded:

        $wsdl = "<?xml version='1.0' ?>
                <definitions name='$name' targetNamespace='$uri'
                    xmlns='http://schemas.xmlsoap.org/wsdl/'
                    xmlns:tns='$uri'
                    xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
                    xmlns:xsd='http://www.w3.org/2001/XMLSchema'
                    xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/'
                    xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'></definitions>";
    

    The above snippet of code is from line 91 of Zend/Soap/Wsdl.php. So the simple fix to your problem is to modify the first line of the above code to include the encoding:

        $wsdl = "<?xml version='1.0' encoding='UTF-8' ?>
    

    I just ran this code and it achieved the desired outcome. And I wouldn't be too fussed about having to modify the framework code. I have a standard set of patches that I've been running over the top of ZF1 ever since about 1.7 to fix a few little oddities that I didn't agree with. That's the beauty of open source - you don't have to pay some company thousands of dollars to make a one-line change! Just make sure you remember to re-run your patch if you ever upgrade to the next maintenance release of ZF1 (assuming one comes along).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?