调试青海联通VAC接口,根据VAC SP接口规范1212中的wsdl文件,采用axis生成WebService服务,调试时发现青海联通VAC发送的请求解析老是出错:
2010-07-09 13:52:44,627[DEBUG]org.apache.axis.enterprise(325) - Mapping Exception to AxisFault org.xml.sax.SAXException: Invalid element in com.unicom.vac.bossagent.soap.sync.req.OrderRelationUpdateNotifyRequest - userIdType at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258) at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035) at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
后来通过axis的SOAPMonitor,发现联通给过来的VAC同步请求消息和规范中的wsdl定义不一样,修改了wsdl文件,重新生成WebService代码,再次测试成功。
修改后的wsdl如下:
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:tns3="http://rsp.sync.soap.bossagent.vac.unicom.com" xmlns:impl="http://soap.bossagent.vac.unicom.com" xmlns:intf="http://soap.bossagent.vac.unicom.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns2="http://req.sync.soap.bossagent.vac.unicom.com" xmlns:tns4="http://type.sync.soap.bossagent.vac.unicom.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://soap.bossagent.vac.unicom.com"> <wsdl:types> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://req.sync.soap.bossagent.vac.unicom.com"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="OrderRelationUpdateNotifyRequest"> <sequence> <element name="recordSequenceId" nillable="true" type="soapenc:string"/> <element name="userIdType" nillable="true" type="soapenc:int"/> <element name="userId" nillable="true" type="soapenc:string"/> <element name="serviceType" nillable="true" type="soapenc:string"/> <element name="spId" nillable="true" type="soapenc:string"/> <element name="productId" nillable="true" type="soapenc:string"/> <element name="updateType" nillable="true" type="soapenc:int"/> <element name="updateTime" nillable="true" type="soapenc:string"/> <element name="updateDesc" nillable="true" type="soapenc:string"/> <element name="linkId" nillable="true" type="soapenc:string"/> <element name="content" nillable="true" type="soapenc:string"/> <element name="effectiveDate" nillable="true" type="soapenc:string"/> <element name="expireDate" nillable="true" type="soapenc:string"/> <element name="time_stamp" nillable="true" type="soapenc:string"/> <element name="encodeStr" nillable="true" type="soapenc:string"/> </sequence> </complexType> </schema> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://rsp.sync.soap.bossagent.vac.unicom.com"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="OrderRelationUpdateNotifyResponse"> <sequence> <element name="recordSequenceId" nillable="true" type="soapenc:string"/> <element name="resultCode" type="xsd:int"/> </sequence> </complexType> </schema> </wsdl:types> <wsdl:message name="orderRelationUpdateNotifyRequest"> <wsdl:part name="orderRelationUpdateNotifyRequest" type="tns2:OrderRelationUpdateNotifyRequest"/> </wsdl:message> <wsdl:message name="orderRelationUpdateNotifyResponse"> <wsdl:part name="orderRelationUpdateNotifyReturn" type="tns3:OrderRelationUpdateNotifyResponse"/> </wsdl:message> <wsdl:portType name="SyncNotifySPService"> <wsdl:operation name="orderRelationUpdateNotify" parameterOrder="orderRelationUpdateNotifyRequest"> <wsdl:input name="orderRelationUpdateNotifyRequest" message="impl:orderRelationUpdateNotifyRequest"/> <wsdl:output name="orderRelationUpdateNotifyResponse" message="impl:orderRelationUpdateNotifyResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SyncNotifySPSoapBinding" type="impl:SyncNotifySPService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="orderRelationUpdateNotify"> <wsdlsoap:operation/> <wsdl:input> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.bossagent.vac.unicom.com"/> </wsdl:input> <wsdl:output> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.bossagent.vac.unicom.com"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SyncNotifySPServiceService"> <wsdl:port name="SyncNotifySP" binding="impl:SyncNotifySPSoapBinding"> <wsdlsoap:address location="http://localhost/services/VacSync"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
规范中的wsdl文件如下:
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:tns3="http://rsp.sync.soap.bossagent.vac.unicom.com" xmlns:impl="http://soap.bossagent.vac.unicom.com" xmlns:intf="http://soap.bossagent.vac.unicom.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns2="http://req.sync.soap.bossagent.vac.unicom.com" xmlns:tns4="http://type.sync.soap.bossagent.vac.unicom.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://soap.bossagent.vac.unicom.com"> <wsdl:types> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://req.sync.soap.bossagent.vac.unicom.com"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="ArrayOf_tns2_SubInfo"> <sequence> <element maxOccurs="unbounded" minOccurs="1" name="item" type="tns2:SubInfo"/> </sequence> </complexType> <complexType name="OrderRelationUpdateNotifyRequest"> <sequence> <element name="recordSequenceId" nillable="true" type="soapenc:string"/> <element name="subNotify" type="tns2:ArrayOf_tns2_SubInfo"/> </sequence> </complexType> <complexType name="SubInfo"> <sequence> <element name="userIdType" nillable="true" type="soapenc:int"/> <element name="userId" nillable="true" type="soapenc:string"/> <element name="serviceType" nillable="true" type="soapenc:string"/> <element name="spId" nillable="true" type="soapenc:string"/> <element name="sp_productId" nillable="true" type="soapenc:string"/> <element name="updateType" nillable="true" type="soapenc:int"/> <element name="updateTime" nillable="true" type="soapenc:string"/> <element name="updateDesc" nillable="true" type="soapenc:string"/> <element name="linkId" nillable="true" type="soapenc:string"/> <element name="content" nillable="true" type="soapenc:string"/> <element name="effectiveDate" nillable="true" type="soapenc:string"/> <element name="expireDate" nillable="true" type="soapenc:string"/> <element name="time_stamp" nillable="true" type="soapenc:string"/> <element name="encodeStr" nillable="true" type="soapenc:string"/> <element name="accessNo" nillable="true" type="soapenc:string"/> </sequence> </complexType> </schema> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://rsp.sync.soap.bossagent.vac.unicom.com"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="OrderRelationUpdateNotifyResponse"> <sequence> <element name="recordSequenceId" nillable="true" type="soapenc:string"/> <element name="resultCode" type="xsd:int"/> </sequence> </complexType> </schema> </wsdl:types> <wsdl:message name="orderRelationUpdateNotifyRequest"> <wsdl:part name="orderRelationUpdateNotifyRequest" type="tns2:OrderRelationUpdateNotifyRequest"/> </wsdl:message> <wsdl:message name="orderRelationUpdateNotifyResponse"> <wsdl:part name="orderRelationUpdateNotifyReturn" type="tns3:OrderRelationUpdateNotifyResponse"/> </wsdl:message> <wsdl:portType name="SyncNotifySPService"> <wsdl:operation name="orderRelationUpdateNotify" parameterOrder="orderRelationUpdateNotifyRequest"> <wsdl:input name="orderRelationUpdateNotifyRequest" message="impl:orderRelationUpdateNotifyRequest"/> <wsdl:output name="orderRelationUpdateNotifyResponse" message="impl:orderRelationUpdateNotifyResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SyncNotifySPSoapBinding" type="impl:SyncNotifySPService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="orderRelationUpdateNotify"> <wsdlsoap:operation/> <wsdl:input> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.bossagent.vac.unicom.com"/> </wsdl:input> <wsdl:output> <wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soap.bossagent.vac.unicom.com"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SyncNotifySPServiceService"> <wsdl:port name="SyncNotifySP" binding="impl:SyncNotifySPSoapBinding"> <wsdlsoap:address location="http://localhost/services/VacSync"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
联通VAC接口发过来的WebService请求消息如下:
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns1:orderRelationUpdateNotify soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://soap.bossagent.vac.unicom.com"> <orderRelationUpdateNotifyRequest href="#id0"/> </ns1:orderRelationUpdateNotify> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:OrderRelationUpdateNotifyRequest" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://req.sync.soap.bossagent.vac.unicom.com"> <recordSequenceId xsi:type="soapenc:string">201007091357162383</recordSequenceId> <userIdType href="#id1"/> <userId xsi:type="soapenc:string">8613007794250</userId> <serviceType xsi:type="soapenc:string">31</serviceType> <spId xsi:type="soapenc:string">84407</spId> <productId xsi:type="soapenc:string">3170003901</productId> <updateType href="#id2"/> <updateTime xsi:type="soapenc:string">20100709135716</updateTime> <updateDesc xsi:type="soapenc:string"/> <linkId xsi:type="soapenc:string"/> <content xsi:type="soapenc:string">Qxc</content> <effectiveDate xsi:type="soapenc:string">20100709135536</effectiveDate> <expireDate xsi:type="soapenc:string">20100709135716</expireDate> <time_stamp xsi:type="soapenc:string">0709135716</time_stamp> <encodeStr xsi:type="soapenc:string">fcbf28f61d4182ba72946a494a172801</encodeStr> </multiRef> <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 1 </multiRef> <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"> 2 </multiRef> </soapenv:Body> </soapenv:Envelope>
问了一下青海联通,他们的VAC是华为做的,而且很多业务已经在跑了,真的搞不明白他们怎么调试通过的?
也许是我拿到的wsdl文件就不对,或是他们按照http+xml去自行解析了?
当然这个问题没出去说,也找不到华为的兄弟来讨论,既然已经有那么多业务在跑了,即使是他们未按照正确的规范来做现在也不能改了。
只不过希望使用WebService来做规范的开发人员以后一定要按照规范来做,否则还采用WebService干嘛呢,徒增许多麻烦。