展会信息港展会大全

PHP5 在调用 JAVA WebService 时遇到的各种问题解决方法
来源:互联网   发布日期:2016-03-02 15:41:57   浏览:4838次  

导读:开始gank。服务端:Spring3.0.5+CXF2.4,JDK1.6“应该是”自动生成的wsdl文件<服务端不是我们的>客户端:PHP5.1.3碰见的第一个问题:SOAP-ER...

开始gank。

服务端:

Spring3.0.5+CXF2.4,JDK1.6

“应该是”自动生成的wsdl文件<服务端不是我们的>

客户端:

PHP5.1.3

碰见的第一个问题:

SOAP-ERROR: Encoding: object has no 'id' property

但是API文档上说不需要id,查看wsdl文件内容

<xs:complexType name="seal"><xs:sequence><xs:element name="id" type="xs:long"/><xs:element minOccurs="0" name="name" type="xs:long"/>

查阅schema文档,有如下内容:

通过 schema,我们可使用 maxOccurs 和 minOccurs 属性来定义某个元素可能出现的次数。maxOccurs 定义某元素出现次数的最大值,而 minOccurs 则定义某元素出现次数的最小值。maxOccurs 和 minOccurs 的默认值都是 1!(好吧,这个是服务端的问题?然后自己随便写了个值,通过了。。。)

PS:中间有个小环节,我尽然去看了PHP的源代码。。。

SOAP中的php_encoding.c里面的函数 model_to_xml_object

static int model_to_xml_object(xmlNodePtr node, sdlContentModelPtr model, zval *object, int style, int strict TSRMLS_DC)

//一小段代码

} else if (model->min_occurs == 0) {

return 2;

} else {

if (strict) {

soap_error1(E_ERROR, "Encoding: object has no '%s' property", model->u.element->name);//明显就是<span style="font-family:Times New Roman;">它!</span>

}

return 0;

}

我是从这里发现问题出现在min_occurs上,所以才解决了上面问题(是不是对方不太规范?)

第二个问题:

looks like we got no XML document

这个可是郁闷了,解决了好久

已经返回来数据了,然后我抓包(貌似有方法可以直接显示数据),发现返回的数据类似如下格式:

HTTP/1.1 200 OK

Server: Apache-Coyote/1.1

Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:0c37c356-41de-4361-9835-ab8dc023dcac"; start="<root.message@cxf.apache.org>"; start-info="text/xml"

Content-Length: 790

Date: Tue, 04 Dec 2012 07:57:45 GMT

--uuid:0c37c356-41de-4361-9835-ab8dc023dcac

Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";

Content-Transfer-Encoding: binary

Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:createSealResponse xmlns:ns2="http://service.api.seal.kx.knet.cn/"><return><code>2003</code><date>2012-12-04 15:57:46.124</date><msg>Logic error</msg><result>sfn004.cn:瀵逛

赞助本站

人工智能实验室

相关热词: 开发 编程 android

相关内容
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港