SpringFrameworkでApache CXF 2.6.3を使用してXSD経由で簡単なSOAP Webサービスを作成しました。Apache CXF 2.6.3 SpringframeworkでSOAP WSをスローcvc-elt.1:要素 'ns2:blah'の宣言が見つかりません
私はXSDスキーマの検証に関する問題に直面しています。私はそれがXSDの問題であり、それを特定できないと思う。私の目は疲れていて、どんな助けでも大歓迎です。
これはSOAP-UIを介して送信されたリクエストです。
SOAPリクエスト:以下
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<soapenv:Header/>
<soapenv:Body>
<sch:promoteProductWebserviceRequest>
<productName>MyMerc</productName>
<reqReceivedDate>12/13/2017</reqReceivedDate>
</sch:promoteProductWebserviceRequest>
</soapenv:Body>
</soapenv:Envelope>
スキーマ検証が有効になってがfalseに設定して、trueに設定されている場合の応答は、受信されています。
schema-validation-enabledがfalseに設定されていると、正常に動作します。
ns2:promoteProductWebserviceResponse
レスポンスオブジェクトPromoteProductResponse.xsdは独自の名前空間を持っているにもかかわらず:
"http://schema.promoteproduct.services.mas.cms.ravs.com/"
SOAP応答:(とき応答は、名前空間を持って来ていることを
注意スキーマ検証有効化偽)
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:promoteProductWebserviceResponse xmlns:ns2="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<transactionStatus>true</transactionStatus>
<transactionId>1000</transactionId>
<messageList>
<ns2:errorMessage/>
</messageList>
</ns2:promoteProductWebserviceResponse>
</soap:Body>
</soap:Envelope>
SOAP応答:春beans.xmlの下に
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Marshalling Error: cvc-elt.1: Cannot find the declaration of element 'ns2:promoteProductWebserviceResponse'.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
さフォルト文字列とは(スキーマ検証が有効になっては真に設定した場合)以下
<?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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<jaxws:endpoint
id="promoteProduct"
implementor="com.ravs.cms.mas.services.promoteproduct.PromoteProductWebServiceProvider"
address="/PromoteProduct">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
</beans>
WSDL:
http://localhost:8080/PromoteProduct-WS-0.0.1-SNAPSHOT/PromoteProduct?wsdl
<?xml version="1.0" ?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://schema.promoteproduct.services.mas.cms.ravs.com/" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/" name="PromoteProductWebService" targetNamespace="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://schema.promoteproduct.services.mas.cms.ravs.com/" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:import namespace="http://schema.promoteproduct.services.mas.cms.ravs.com/" schemaLocation="http://localhost:8080/PromoteProduct-WS-0.0.1-SNAPSHOT/PromoteProduct?xsd=xmlSchema/PromoteProductRequest.xsd"></xsd:import>
<xsd:import namespace="http://schema.promoteproduct.services.mas.cms.ravs.com/" schemaLocation="http://localhost:8080/PromoteProduct-WS-0.0.1-SNAPSHOT/PromoteProduct?xsd=xmlSchema/PromoteProductResponse.xsd"></xsd:import>
<xsd:import namespace="http://schema.promoteproduct.services.mas.cms.ravs.com/" schemaLocation="http://localhost:8080/PromoteProduct-WS-0.0.1-SNAPSHOT/PromoteProduct?xsd=xmlSchema/PromoteProductWebserviceException.xsd"></xsd:import>
</xsd:schema>
</wsdl:types>
<wsdl:message name="promoteProductWebserviceReq">
<wsdl:part element="tns:promoteProductWebserviceRequest" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="promoteProductWebserviceEx">
<wsdl:part element="tns:promoteProductWebserviceException" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="promoteProductWebserviceRes">
<wsdl:part element="tns:promoteProductWebserviceResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="PromoteProductWebService">
<wsdl:operation name="getPromoteProduct">
<wsdl:input message="tns:promoteProductWebserviceReq">
</wsdl:input>
<wsdl:output message="tns:promoteProductWebserviceRes">
</wsdl:output>
<wsdl:fault message="tns:promoteProductWebserviceEx" name="promoteProductWebserviceEx">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PromoteProductWebService" type="tns:PromoteProductWebService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
<wsdl:operation name="getPromoteProduct">
<soap:operation soapAction="getPromoteProduct" style="document"></soap:operation>
<wsdl:input>
<soap:body use="literal"></soap:body>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"></soap:body>
</wsdl:output>
<wsdl:fault name="promoteProductWebserviceEx">
<soap:fault name="promoteProductWebserviceEx" use="literal"></soap:fault>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PromoteProductWebService">
<wsdl:port binding="tns:PromoteProductWebService" name="PromoteProductWebService">
<soap:address location="http://localhost:8080/PromoteProduct-WS-0.0.1-SNAPSHOT/PromoteProduct"></soap:address>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
1 PromoteProductRequest.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://schema.promoteproduct.services.mas.cms.ravs.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:element name="promoteProductWebserviceRequest" type="mas:promoteProductWebserviceRequest">
</xsd:element>
<xsd:complexType name="promoteProductWebserviceRequest">
<xsd:sequence>
<xsd:element name="productName" maxOccurs="1" minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="30" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="reqReceivedDate" maxOccurs="1" minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1" />
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
2 PromoteProductResponse.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://schema.promoteproduct.services.mas.cms.ravs.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:include schemaLocation="PromoteProductMessage.xsd"></xsd:include>
<xsd:element name="promoteProductWebserviceResponse" type="mas:promoteProductWebserviceResponse">
</xsd:element>
<xsd:complexType name="promoteProductWebserviceResponse" xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:sequence>
<xsd:element name="transactionStatus" type="xsd:boolean" maxOccurs="1" minOccurs="1"></xsd:element>
<xsd:element name="transactionId" type="xsd:long" maxOccurs="1" minOccurs="1"></xsd:element>
<xsd:element name="messageList" type="mas:messageList" maxOccurs="1" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
3 PromoteProductMessage.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schema.promoteproduct.services.mas.cms.ravs.com/"
xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:complexType name="messageList">
<xsd:sequence>
<xsd:element name="errorMessage" type="mas:messageDetail" maxOccurs="unbounded" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="messageDetail">
<xsd:sequence>
<xsd:element name="errorCode" type="xsd:string"></xsd:element>
<xsd:element name="errorMessage" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
4. PromoteProductWebserviceException.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://schema.promoteproduct.services.mas.cms.ravs.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
xmlns:mas="http://schema.promoteproduct.services.mas.cms.ravs.com/">
<xsd:include schemaLocation="PromoteProductMessage.xsd"></xsd:include>
<xsd:element name="promoteProductWebserviceException">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1"
name="errMsgList" type="mas:messageList">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>