douershuang7356 2015-11-09 13:45
浏览 69
已采纳

Codeception SOAP API测试:实体异常中文档末尾的额外内容

I am trying to use Codeception to test my SOAP API calls but i ran into some problems. When trying to pass the auth header through haveSoapHeader() method i get:

[PHPUnit_Framework_Exception] DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 2

api.suite.yml:

class_name: ApiTester
modules:
    enabled:
        - \Helper\Api
        - PhpBrowser
        - SOAP
    config:
        PhpBrowser:
            url: 'http://localhost'
        SOAP:
            depends: PhpBrowser
            endpoint: http://localhost:888/soap

testCallCept.php:

$I = new ApiTester($scenario);
$I->wantTo('perform actions and see result');
$I->haveSoapHeader(
    'authenticate',
    array(
        'username' => 'test',
        'password' => 'test'
    )
);

$I->sendSoapRequest('testCall');

When running this test in debug mode i get the following:

C:\xampp\htdocs\xyz>php codecept.phar run api -d
Codeception PHP Testing Framework v2.1.3
Powered by PHPUnit 4.8.10 by Sebastian Bergmann and contributors.

←[1mApi Tests (1) ←[22m----------------------------------------------------------------------------------------------
Modules: ←[32m\Helper\Api, PhpBrowser, SOAP←[39m
------------------------------------------------------------------------------------------------------------
←[35;1mPerform actions and see result←[39;22m (testCallCept)
Scenario:
* I have soap header "authenticate",{"username":"test","password":"test"}
* I send soap request "test"

←[36m  [Request] <soapenv:Envelope xmlns:ns="" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">←[39m←[36m<authenticate>←[39m←[36m<username>←[39m←[36mtest←[39m←[36m</username>←[3
9m←[36m<password>←[39m←[36mtest←[39m←[36m</password>←[39m←[36m</authenticate>←[39m←[36m</soapenv:Header><soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><ns:testCall></ns:testCall></soapenv:Body></soapenv:Envelope>←[39m
←[36m  [Response] <br />
  <font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  ←[39m←[36m<tr>←[39m←[36m<th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )←[39m←[36m</span>←[39m←[36m Warning: si←[39m
←[37;41m ERROR ←[39;49m

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------------------------------------------------------------------------------------


Time: 554 ms, Memory: 9.50Mb

There was 1 error:

---------
1) Failed to perform actions and see result in ←[1mtestCallCept←[22m (tests\api\\testCallCept.php)

←[37;41m                                                                                                                     ←[39;49m
←[37;41m  [PHPUnit_Framework_Exception] DOMDocument::loadXML(): Extra content at the end of the document in Entity, line: 2  ←[39;49m
←[37;41m                                                                                                                     ←[39;49m
←[33m
Scenario Steps:
←[39m
←[1m 2. $I->sendSoapRequest("test")←[22m at ←[32mtests\api\testCallCept.php:14←[39m
 1. $I->haveSoapHeader("authenticate",{"username":"test","password":"test"}) at ←[32mtests\api\testCallCept.php:12←[39m

#1  Codeception\Subscriber\ErrorHandler->errorHandler
#2  Codeception\Module\SOAP->sendSoapRequest
#3  C:\xampp\htdocs\xyz\tests\_support\_generated\ApiTesterActions.php:2067
#4  C:\xampp\htdocs\xyz\tests\api\testCallCept.php:14
#5  C:\xampp\htdocs\xyz\codecept.phar:7

←[37;41mFAILURES!←[0m
←[37;41mTests: 1←[0m←[37;41m, Assertions: 0←[0m←[37;41m, Errors: 1←[0m←[37;41m.←[0m

I have searched what could be the problem of it and stumbled upon a post saying that it happens when xml structure is not valid but as long as i can see the structure is how it is supposed to be so i really have no idea where to look next.

Anybody has any idea what could be the problem?

  • 写回答

1条回答 默认 最新

  • doujin8673 2015-11-09 14:25
    关注

    I had an error in SOAP server configuration and thus getting the error in SOAP response which i didn't notice at first.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?