0

我们正在创建 CXF SOAP 合同优先的 Web 服务。为此,我们构建了 xsd,然后使用 XJC 生成 java 类。然后,我们为端点及其实现创建一个接口。在 spring 文件中,我们声明我们的端点,我们激活验证并设置 shemaLocation。如果我们使用 SOAPUI 测试 Web 服务(并在 SOAPUI 中激活请求和响应的验证),我们会在响应中收到验证错误

“第 4 行:预期元素 'responses@...' 而不是 'readItemsResponse@...' 在元素 readItemsResponse@... 中”

服务器端没有错误。如果我们关闭 SOAPUI 的响应验证,一切正常。即使一切都按照 xsd 完成,怎么可能出现这种错误。

春季声明摘录:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd" xmlns:cxf="http://cxf.apache.org/core"
default-dependency-check="none" default-lazy-init="false">

<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

<cxf:bus>
    <cxf:inInterceptors>
        <ref bean="logInbound"/>
    </cxf:inInterceptors>
    <cxf:outInterceptors>
        <ref bean="logOutbound"/>
    </cxf:outInterceptors>
    <cxf:outFaultInterceptors>
        <ref bean="logOutbound"/>
    </cxf:outFaultInterceptors>
    <cxf:inFaultInterceptors>
        <ref bean="logInbound"/>
    </cxf:inFaultInterceptors>
</cxf:bus> 

<jaxws:endpoint id="gen.kernel.ItemSOA" implementor="fr.vif.vif5_7.gen.item.soa.endpoint.item.ItemEndPoint"
    address="/gen/kernel/ItemSOA">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
    <jaxws:schemaLocations>
        <jaxws:schemaLocation>classpath:/gen/item/soa/schemas/item/ItemSOA.xsd</jaxws:schemaLocation>
    </jaxws:schemaLocations>
</jaxws:endpoint>

<bean id="SoaitemPPO" class="fr.vif.vif5_7.gen.item.soa.endpoint.item.proxy.SoaitemPPO" />

发送的 SOAP 消息:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ker="http://www.vif.fr/vif5_7/gen/kernel">
   <soapenv:Header/>
   <soapenv:Body>
       <ker:readItems>
         <!--Optional:-->
         <ker:readItemsRequest>
            <!--Optional:-->
            <ker:generalInfos>
               <!--Optional:-->
               <ker:consumerId>?</ker:consumerId>
            </ker:generalInfos>
            <ker:itemSelection>
               <ker:company>OM</ker:company>
               <ker:establishment>01</ker:establishment>
               <ker:itemSelection>
                  <ker:item>CREPE</ker:item>
                </ker:itemSelection>
            </ker:itemSelection>
         </ker:readItemsRequest>
       </ker:readItems>
   </soapenv:Body>
</soapenv:Envelope>

收到 SOAP 消息:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <ns1:readItemsResponse xmlns:ns1="http://www.vif.fr/vif5_7/gen/kernel">
     <ns1:readItemsResponse>
        <ns1:responses>
           <ns1:response>
              <ns1:codeItem>CREPE</ns1:codeItem>
              <ns1:standardResponses>
                 <ns1:standardResponse>
                    <ns1:status>OK</ns1:status>
                    <ns1:message>Item : CREPE - crepe hb</ns1:message>
                 </ns1:standardResponse>
              </ns1:standardResponses>
           </ns1:response>
        </ns1:responses>
        <ns1:items>
           <ns1:item>
              <ns1:company>OM</ns1:company>
              <ns1:etablishment>01</ns1:etablishment>
              <ns1:codeItem>CREPE</ns1:codeItem>
              <ns1:itemMandatoryInfo>
                 <ns1:itemDesignation>crepe hb</ns1:itemDesignation>
                 <ns1:itemShortDesign>crepe</ns1:itemShortDesign>
                 <ns1:codeBasicFam>SF</ns1:codeBasicFam>
                 <ns1:codeAccountingFam>01</ns1:codeAccountingFam>
                 <ns1:itemType>Goods</ns1:itemType>
              </ns1:itemMandatoryInfo>
              <ns1:itemUnit>
                 <ns1:firstUnit>P</ns1:firstUnit>
                 <ns1:secondUnit>Kg</ns1:secondUnit>
                 <ns1:firstUnitCoef>1.0</ns1:firstUnitCoef>
                 <ns1:secondUnitCoef>0.5</ns1:secondUnitCoef>
                 <ns1:isConstantQuantity>false</ns1:isConstantQuantity>
                 <ns1:codeEnteredFirstUnit>P</ns1:codeEnteredFirstUnit>
              </ns1:itemUnit>
              <ns1:itemGeneralInfo>
                 <ns1:otherId1>00000</ns1:otherId1>
                 <ns1:isMiscItem>false</ns1:isMiscItem>
                 <ns1:tare>
                    <ns1:qty>0.1</ns1:qty>
                    <ns1:unit>Kg</ns1:unit>
                 </ns1:tare>
                 <ns1:eanData>
                    <ns1:eanType>DUN14</ns1:eanType>
                    <ns1:ean>106789014</ns1:ean>
                    <ns1:guideWeight>21</ns1:guideWeight>
                    <ns1:guidePrice>02</ns1:guidePrice>
                    <ns1:codeRetailUnit>CAR</ns1:codeRetailUnit>
                    <ns1:nbOUT>1</ns1:nbOUT>
                    <ns1:nbINNER>1</ns1:nbINNER>
                    <ns1:nbOU>1</ns1:nbOU>
                    <ns1:nbLayers>2</ns1:nbLayers>
                    <ns1:eanLevel>Consumer unit</ns1:eanLevel>
                 </ns1:eanData>
                 <ns1:validityPeriod>
                    <ns1:dateStart>2004-10-25T00:00:00.000+02:00</ns1:dateStart>
                    <ns1:dateEnd>2999-12-31T00:00:00.000+01:00</ns1:dateEnd>
                 </ns1:validityPeriod>
              </ns1:itemGeneralInfo>
              <ns1:heldInStockData>
                 <ns1:isFirstUnitIsStock>true</ns1:isFirstUnitIsStock>
                 <ns1:isSecondUnitIsStock>true</ns1:isSecondUnitIsStock>
                 <ns1:isHeldByBatch>true</ns1:isHeldByBatch>
                 <ns1:isReserved>false</ns1:isReserved>
                 <ns1:codeRawMaterialDepot>GEN</ns1:codeRawMaterialDepot>
                 <ns1:codeRawMaterialLocation/>
                 <ns1:picking>FIFO</ns1:picking>
                 <ns1:codeInventoryFrequency>Free</ns1:codeInventoryFrequency>
                 <ns1:costType>$LOT</ns1:costType>
                 <ns1:codeStockCostingUnit>Kg</ns1:codeStockCostingUnit>
                 <ns1:isAllocatedAutomatically>false</ns1:isAllocatedAutomatically>
                 <ns1:batchType>Mono item</ns1:batchType>
                 <ns1:codeRefItem>CREPE</ns1:codeRefItem>
                 <ns1:nbStorage>10.0</ns1:nbStorage>
                 <ns1:nbOptimalStorage>90.0</ns1:nbOptimalStorage>
                 <ns1:NbDaysGuaranteedReceipt>0.0</ns1:NbDaysGuaranteedReceipt>
                 <ns1:NbDaysGuaranteedShipping>0.0</ns1:NbDaysGuaranteedShipping>
                 <ns1:MaxAgeReceipt>0.0</ns1:MaxAgeReceipt>
                 <ns1:StockCheckingUnit>Kg</ns1:StockCheckingUnit>
                 <ns1:qualityData>
                    <ns1:lockStatus>B01</ns1:lockStatus>
                    <ns1:useStatus>D01</ns1:useStatus>
                    <ns1:outsideLimitStatus>P01</ns1:outsideLimitStatus>
                    <ns1:lockingDuration>0.0</ns1:lockingDuration>
                    <ns1:useDuration>30.0</ns1:useDuration>
                    <ns1:manualUnlocking>false</ns1:manualUnlocking>
                 </ns1:qualityData>
                 <ns1:replenishmentUnit>Kg</ns1:replenishmentUnit>
                 <ns1:safetyStock>60000.0</ns1:safetyStock>
                 <ns1:maxStock>0.0</ns1:maxStock>
                 <ns1:coverage>0.0</ns1:coverage>
              </ns1:heldInStockData>
              <ns1:soldItemData>
                 <ns1:itemSalesDesignation>crepe</ns1:itemSalesDesignation>
                 <ns1:preferedOrderUnit>P</ns1:preferedOrderUnit>
                 <ns1:preferedPriceUnit>P</ns1:preferedPriceUnit>
                 <ns1:isRPManagement>false</ns1:isRPManagement>
                 <ns1:salesPeriod>
                    <ns1:dateStart>2004-10-25T00:00:00.000+02:00</ns1:dateStart>
                    <ns1:dateEnd>2999-12-31T00:00:00.000+01:00</ns1:dateEnd>
                 </ns1:salesPeriod>
                 <ns1:codeSalesModel>Normal</ns1:codeSalesModel>
                 <ns1:isFree>false</ns1:isFree>
                 <ns1:codePriceItem>CREPE</ns1:codePriceItem>
                 <ns1:isCompound>false</ns1:isCompound>
                 <ns1:isRPCompound>true</ns1:isRPCompound>
                 <ns1:criterionUBDorBBD/>
                 <ns1:typeUBDorBBD>UBD</ns1:typeUBDorBBD>
                 <ns1:prepaPeriod>0</ns1:prepaPeriod>
                 <ns1:prepaPeriodTime>0</ns1:prepaPeriodTime>
                 <ns1:preparationShippingAreas>
                    <ns1:prepaShippingArea>
                       <ns1:codePreparationWorkshop>01</ns1:codePreparationWorkshop>
                       <ns1:codeShippingArea>01</ns1:codeShippingArea>
                       <ns1:shippingDepot>EXP</ns1:shippingDepot>
                       <ns1:returnDepot>EXP</ns1:returnDepot>
                       <ns1:isPreferredArea>true</ns1:isPreferredArea>
                    </ns1:prepaShippingArea>
                 </ns1:preparationShippingAreas>
              </ns1:soldItemData>
              <ns1:purchasesData>
                 <ns1:isReceivedInWorkshop>false</ns1:isReceivedInWorkshop>
                 <ns1:purchasePeriod>
                    <ns1:dateStart>2005-10-25T00:00:00.000+02:00</ns1:dateStart>
                    <ns1:dateEnd>2012-12-31T00:00:00.000+01:00</ns1:dateEnd>
                 </ns1:purchasePeriod>
                 <ns1:receiptAreas>
                    <ns1:receiptArea>
                       <ns1:codeArea/>
                       <ns1:codeEndDepot>GEN</ns1:codeEndDepot>
                       <ns1:codeEndLocation/>
                       <ns1:isPreferredArea>true</ns1:isPreferredArea>
                    </ns1:receiptArea>
                    <ns1:receiptArea>
                       <ns1:codeArea>E01</ns1:codeArea>
                       <ns1:codeEndDepot>GE2</ns1:codeEndDepot>
                       <ns1:codeEndLocation>A1</ns1:codeEndLocation>
                       <ns1:isPreferredArea>false</ns1:isPreferredArea>
                    </ns1:receiptArea>
                 </ns1:receiptAreas>
              </ns1:purchasesData>
              <ns1:manufacturingData>
                 <ns1:isGenericValue>false</ns1:isGenericValue>
                 <ns1:codeWorkshopInputProfile/>
                 <ns1:codeWorkshopOutputProfile/>
                 <ns1:codeProdInputProfile/>
                 <ns1:codeProdOutputProfile/>
                 <ns1:shrinkageRate>0.0</ns1:shrinkageRate>
                 <ns1:ManufacturingToBeCosted>false</ns1:ManufacturingToBeCosted>
                 <ns1:purchasedItem>
                    <ns1:leadTime>0.0</ns1:leadTime>
                    <ns1:buyReplenishmentRule>Batch for batch</ns1:buyReplenishmentRule>
                    <ns1:orderPoint>0.0</ns1:orderPoint>
                    <ns1:minBuy>0.0</ns1:minBuy>
                    <ns1:multipleBuy>0.0</ns1:multipleBuy>
                 </ns1:purchasedItem>
                 <ns1:manufacturedItem>
                    <ns1:itemInput>CREPE</ns1:itemInput>
                    <ns1:itemOutput>CREPE</ns1:itemOutput>
                    <ns1:startType>Pull</ns1:startType>
                    <ns1:moDesignationRule>F01</ns1:moDesignationRule>
                    <ns1:replenishentRule>Batch for batch</ns1:replenishentRule>
                    <ns1:minReplenishment>0.0</ns1:minReplenishment>
                    <ns1:multipleReplenishment>0.0</ns1:multipleReplenishment>
                    <ns1:maxReplenishment>0.0</ns1:maxReplenishment>
                 </ns1:manufacturedItem>
              </ns1:manufacturingData>
              <ns1:preparationData>
                 <ns1:itemComposition>OM</ns1:itemComposition>
                 <ns1:groupRPCharacteristic>Fixed weight</ns1:groupRPCharacteristic>
                 <ns1:preparationType>By transformation of product</ns1:preparationType>
                 <ns1:preparationProfil>$000002001</ns1:preparationProfil>
                 <ns1:codeItemToPrepare>CREPE</ns1:codeItemToPrepare>
                 <ns1:codePreparationUnit>P</ns1:codePreparationUnit>
              </ns1:preparationData>
              <ns1:downgradedItems>
                 <ns1:codeDowngradedItem>CREPE2</ns1:codeDowngradedItem>
              </ns1:downgradedItems>
              <ns1:companyDescCriteria>
                 <ns1:criterion>
                    <ns1:criterionCode>$ORIGINE</ns1:criterionCode>
                    <ns1:stringValue>
                       <ns1:stringValueUnique/>
                    </ns1:stringValue>
                 </ns1:criterion>
                 <ns1:criterion>
                    <ns1:criterionCode>EAN-UVC</ns1:criterionCode>
                    <ns1:stringValue>
                       <ns1:stringValueUnique>123</ns1:stringValueUnique>
                    </ns1:stringValue>
                 </ns1:criterion>
              </ns1:companyDescCriteria>
              <ns1:establishmentDescCriteria>
                 <ns1:criterion>
                    <ns1:criterionCode>$ARTGEN</ns1:criterionCode>
                    <ns1:stringValue>
                       <ns1:stringValueUnique/>
                    </ns1:stringValue>
                 </ns1:criterion>
                 <ns1:criterion>
                    <ns1:criterionCode>$TOLFAB</ns1:criterionCode>
                    <ns1:doubleValue>
                       <ns1:doubleValueBound>
                          <ns1:doubleValueMin>10.0</ns1:doubleValueMin>
                          <ns1:doubleValueMax>15.0</ns1:doubleValueMax>
                       </ns1:doubleValueBound>
                    </ns1:doubleValue>
                 </ns1:criterion>
                 <ns1:criterion>
                    <ns1:criterionCode>PATE</ns1:criterionCode>
                    <ns1:stringValue>
                       <ns1:stringValueUnique/>
                    </ns1:stringValue>
                 </ns1:criterion>
              </ns1:establishmentDescCriteria>
              <ns1:allergens>
                 <ns1:allergen>
                    <ns1:criterionData>
                       <ns1:criterionCode>$ALCELER</ns1:criterionCode>
                       <ns1:stringValue>
                          <ns1:stringValueUnique>N/A</ns1:stringValueUnique>
                       </ns1:stringValue>
                    </ns1:criterionData>
                    <ns1:locked>false</ns1:locked>
                    <ns1:reason/>
                 </ns1:allergen>
                 <ns1:allergen>
                    <ns1:criterionData>
                       <ns1:criterionCode>$ALLAIT</ns1:criterionCode>
                       <ns1:stringValue>
                          <ns1:stringValueUnique>N/A</ns1:stringValueUnique>
                       </ns1:stringValue>
                    </ns1:criterionData>
                    <ns1:locked>false</ns1:locked>
                    <ns1:reason/>
                 </ns1:allergen>
              </ns1:allergens>
              <ns1:hierarchies>
                 <ns1:hierarchy>
                    <ns1:codeHierarchy>CREPE</ns1:codeHierarchy>
                    <ns1:codeHierarchyValue>SF</ns1:codeHierarchyValue>
                 </ns1:hierarchy>
                 <ns1:hierarchy>
                    <ns1:codeHierarchy>CREPEDD</ns1:codeHierarchy>
                    <ns1:codeHierarchyValue>01</ns1:codeHierarchyValue>
                 </ns1:hierarchy>
                 <ns1:hierarchy>
                    <ns1:codeHierarchy>SAFE</ns1:codeHierarchy>
                    <ns1:codeHierarchyValue>CREPE</ns1:codeHierarchyValue>
                 </ns1:hierarchy>
                 <ns1:hierarchy>
                    <ns1:codeHierarchy>TACTILE</ns1:codeHierarchy>
                    <ns1:codeHierarchyValue>OM</ns1:codeHierarchyValue>
                 </ns1:hierarchy>
              </ns1:hierarchies>
              <ns1:otherUnits>
                 <ns1:unit>
                    <ns1:codeUnit>K</ns1:codeUnit>
                    <ns1:codeRefUnit>Kg</ns1:codeRefUnit>
                    <ns1:isConstantQuantity>false</ns1:isConstantQuantity>
                    <ns1:positiveDiff>0.0</ns1:positiveDiff>
                    <ns1:negativeDiff>0.0</ns1:negativeDiff>
                    <ns1:unitCoef>1.0</ns1:unitCoef>
                    <ns1:refUnitCoef>0.8</ns1:refUnitCoef>
                 </ns1:unit>
                 <ns1:unit>
                    <ns1:codeUnit>L</ns1:codeUnit>
                    <ns1:codeRefUnit>P</ns1:codeRefUnit>
                    <ns1:isConstantQuantity>false</ns1:isConstantQuantity>
                    <ns1:positiveDiff>0.0</ns1:positiveDiff>
                    <ns1:negativeDiff>0.0</ns1:negativeDiff>
                    <ns1:unitCoef>1.0</ns1:unitCoef>
                    <ns1:refUnitCoef>4.0</ns1:refUnitCoef>
                 </ns1:unit>
              </ns1:otherUnits>
           </ns1:item>
        </ns1:items>
     </ns1:readItemsResponse>
  </ns1:readItemsResponse>

使用的 CXF 版本是:2.7.7

任何帮助,将不胜感激。

当我为端点接口指定 targetNamespace 时,就会出现问题。如果我删除此信息,我将不再有验证问题。由于我不想将包名称用作 targetNamespace,因此我需要添加此信息。

4

0 回答 0