gsoap错误:: ClientValidation约束违规:元素

时间:2017-05-30 08:02:32

标签: wsdl gsoap type-mismatch

每当我尝试使用在线测试工具执行服务 getContractHdr 时:

http://www.soapclient.com/soaptest.html

我收到下面列出的错误。类型(inTENANTREFNO)是INTEGER。即使我在TENANTREFNO中放置了类似于33的字段,我仍然会收到“类型不匹配”的错误。此外,该消息指出变量 inTENANTREFNO am 的命名空间相关联,但我不明白为什么gsoap正在进行此分配。

问题

  

如何解决此问题,以便我不再收到错误?有办法吗?   配置这个以便根本不使用命名空间?为什么我   越来越   它在第一位?我已经看到了这条消息here,但目前尚不清楚   至于是否实施这个将解决问题   案例

注意:每当我使用示例生成的.xml文件时,一切正常。我填写了当然的字段。服务运行,我得到数据(正确)回来。我用“ServerName< testfile.xml”

执行它

当我尝试从其中一个在线测试区域执行服务时(如上所述)。它引用“类型不匹配”不起作用。

<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ns="urn:conmony">
 <SOAP-ENV:Body>
  <ns:getContractHdr>
   <ns:inLogonID></ns:inLogonID>
   <ns:inLogonPassword></ns:inLogonPassword>
   <ns:inTENANTREFNO>0</ns:inTENANTREFNO>
   <ns:incallhost></ns:incallhost>
   <ns:incallpid>0</ns:incallpid>
   <ns:incallfilename></ns:incallfilename>
   <ns:incalllineno>0</ns:incalllineno>
  </ns:getContractHdr>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

错误消息

  

SOAP-ENV:ClientValidation约束违规:无效值   element'am:inTENANTREFNO'

SOAP错误消息

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:am="urn:conmony" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Validation constraint violation: invalid value in element 'am:inTENANTREFNO'</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Ran soapcpp2 -c -n -pdukmony - AND - soapcpp2 -c在包含以下内容的文件

//gsoap am service name: conmony 
//gsoap am service style: document 
//gsoap am service encoding: literal 
//gsoap am service location: http://99.33.23.2232:8075 
//gsoap am schema  namespace: urn:conmony

typedef char            *xsd__string; 
typedef char            *xsd__anyURI; 
typedef float           xsd__float; 
typedef long            xsd__int; 
typedef double          xsd__double; 
typedef unsigned        long long xsd__positiveInteger;

typedef struct  am__struct_DBCONTRACTHDR{
        xsd__int        TENANTREFNO;
        xsd__string     FirstName;
        xsd__string     MiddleName;
        xsd__string     LastName;
        xsd__string     EMail;
        xsd__string     CellPhoneNo;
        xsd__string     HomePhoneNo;
        xsd__string     AsgnLogonID;
        xsd__string     WebPicLocation;
        xsd__int        ReturnCode;
        xsd__double     KeyID;
        xsd__string     Message; };

typedef struct am__CONTRACTHDRItems {
        struct am__struct_DBCONTRACTHDR  *__ptr;
        int __size;
        int __offset; };
inTENANTREFNO
int am__getContractHdr(
        xsd__int        inTENANTREFNO,
        xsd__string     inLogonID,
        xsd__string     inLogonPassword,
        xsd__string     incallhost,
        xsd__int        incallpid,
        xsd__string     incallfilename,
        xsd__int        incalllineno,
        struct am__CONTRACTHDRItems *DBListing);

结果是conmony.wsdl文件

<definitions xmlns:tns="urn:conmony/conmony.wsdl" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:am="urn:conmony" xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:HTTP="http://schemas.xmlsoap.org/wsdl/http/" xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/" xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="conmony" targetNamespace="urn:conmony/conmony.wsdl">
<types>
<schema xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:am="urn:conmony" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:conmony" elementFormDefault="qualified" attributeFormDefault="unqualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="struct-DBCONTRACTHDR">
<!--  am__struct_DBCONTRACTHDR  -->
<sequence>
<element name="TENANTREFNO" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<!--  am__struct_DBCONTRACTHDR::TENANTREFNO  -->
<element name="FirstName" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::FirstName  -->
<element name="MiddleName" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::MiddleName  -->
<element name="LastName" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::LastName  -->
<element name="EMail" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::EMail  -->
<element name="CellPhoneNo" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::CellPhoneNo  -->
<element name="HomePhoneNo" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::HomePhoneNo  -->
<element name="AsgnLogonID" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::AsgnLogonID  -->
<element name="WebPicLocation" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::WebPicLocation  -->
<element name="ReturnCode" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<!--  am__struct_DBCONTRACTHDR::ReturnCode  -->
<element name="KeyID" type="xsd:double" minOccurs="1" maxOccurs="1"/>
<!--  am__struct_DBCONTRACTHDR::KeyID  -->
<element name="Message" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__struct_DBCONTRACTHDR::Message  -->
</sequence>
</complexType>
<complexType name="CONTRACTHDRItems">
<!--  am__CONTRACTHDRItems  -->
<sequence>
<element name="item" type="am:struct-DBCONTRACTHDR" minOccurs="0" maxOccurs="unbounded" nillable="false"/>
</sequence>
</complexType>
<!--  operation request element  -->
<element name="getContractHdr">
<complexType>
<sequence>
<element name="inTENANTREFNO" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<!--  am__getContractHdr::inTENANTREFNO  -->
<element name="inLogonID" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__getContractHdr::inLogonID  -->
<element name="inLogonPassword" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__getContractHdr::inLogonPassword  -->
<element name="incallhost" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__getContractHdr::incallhost  -->
<element name="incallpid" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<!--  am__getContractHdr::incallpid  -->
<element name="incallfilename" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__getContractHdr::incallfilename  -->
<element name="incalllineno" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<!--  am__getContractHdr::incalllineno  -->
</sequence>
</complexType>
</element>
<!--  operation response element  -->
<element name="getContractHdrResponse">
<complexType>
<sequence>
<element name="DBListing" type="am:CONTRACTHDRItems" minOccurs="0" maxOccurs="1" nillable="true"/>
<!--  am__getContractHdr::DBListing  -->
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="getContractHdrRequest">
<part name="Body" element="am:getContractHdr"/>
<!--  am__getContractHdr::am__getContractHdr  -->
</message>
<message name="getContractHdrResponse">
<part name="Body" element="am:getContractHdrResponse"/>
</message>
<portType name="conmonyPortType">
<operation name="getContractHdr">
<documentation>Service definition of function am__getContractHdr</documentation>
<input message="tns:getContractHdrRequest"/>
<output message="tns:getContractHdrResponse"/>
</operation>
</portType>
<binding name="conmony" type="tns:conmonyPortType">
<SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getContractHdr">
<SOAP:operation soapAction=""/>
<input>
<SOAP:body parts="Body" use="literal"/>
</input>
<output>
<SOAP:body parts="Body" use="literal"/>
</output>
</operation>
</binding>
<service name="conmony">
<documentation>gSOAP 2.8.26 generated service definition</documentation>
<port name="conmony" binding="tns:conmony">
<SOAP:address location="http://99.33.23.2232:8075"/>
</port>
</service>
</definitions>

更新: 将soapcpp2运行的文件的标题部分更改为:

//gsoap ns service name: conmony Special SOAP SErvices
//gsoap ns service protocol:    SOAP
//gsoap ns service style: document
//gsoap ns service encoding: literal
//gsoap ns service namespace: http://99.33.23.2232:8075?conmony.wsdl
//gsoap ns service location:  http://99.33.23.2232:8075
//gsoap ns schema  namespace: urn:conmony

仍然遇到同样的问题 但是在填写生成的示例req.xml文件时仍然会获取数据

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="urn:conmony"><SOAP-ENV:Body><ns:getContractHdrResponse><ns:DBListing><ns:item><ns:TENANTREFNO>8288</ns:TENANTREFNO><ns:FirstName>Test</ns:FirstName><ns:MiddleName></ns:MiddleName><ns:LastName>Last</ns:LastName><ns:EMail>testing@last.com</ns:EMail><ns:CellPhoneNo>210-444-2212</ns:CellPhoneNo><ns:HomePhoneNo>210-444-2212</ns:HomePhoneNo><ns:AsgnLogonID>w10testing</ns:AsgnLogonID><ns:WebPicLocation>stuff</ns:WebPicLocation><ns:ReturnCode>0</ns:ReturnCode><ns:KeyID>0.000000</ns:KeyID><ns:Message> testing ...</ns:Message></ns:item></ns:DBListing></ns:getContractHdrResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

“.h文件”和“.c”文件中的所有内容都已更改,因此它使用“ns”命名空间而不是“am”命名空间

0 个答案:

没有答案