我在Endpoint类中的服务方法如下:
@PayloadRoot(namespace=AppExternalServicesConstant.NAMESPACE,localPart="AppPurchaseAddonRequest") @ResponsePayload public AppPurchaseAddonResponse purchaseAddon(@RequestPayload AppPurchaseAddonRequest request) throws ServiceExceptionFault {-- Business logic}
XSD如下所示:
<xs:element name="AppPurchaseAddonRequest" >
<xs:complexType>
<xs:all>
<xs:element name="requestId" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="countryCode" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="addonName" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="number" type="tns:numberType" minOccurs="1" maxOccurs="1"/>
<xs:element name="transactionId" type="tns:transactionIdType" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="AppPurchaseAddonResponse" >
<xs:complexType>
<xs:complexContent>
<xs:extension base="tns:Response">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="Request">
<xs:all>
<xs:element name="requestId" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
<xs:complexType name="Response">
<xs:sequence>
<xs:element name="responseId" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="responseStatus" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<xs:element minOccurs="0" name="responseDescription" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ServiceExceptionFault">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" name="faultInfo" type="tns:AppPurchaseAddonFaultInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="numberType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="transactionIdType">
<xs:restriction base="xs:string">
<xs:maxLength value="20"></xs:maxLength>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="AppPurchaseAddonFaultInfo">
<xs:sequence>
<xs:element minOccurs="0" name="exceptionStack" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="errorCode" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="errorDescription" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
spring-ws-servlet映射文件:
<wss:annotation-driven/>
<context:component-scan base-package="com.ytlc.app"/>
<context:property-placeholder location="file:${environment.properties.file.path}" system-properties-mode="OVERRIDE" ignore-unresolvable="false"/>
<!-- General properties configuration -->
<!-- Spring Security and Validation configuration -->
<wss:interceptors>
<bean class="com.ytlc.ota.ws.services.spring.interceptors.AppPayloadValidationInterceptor">
<property name="schema" value="/WEB-INF/xsd/appservicesv1.xsd"/>
<property name="validateRequest" value="true"/>
<property name="validateResponse" value="false"/>
</bean>
</wss:interceptors>
<bean class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver" />
<!-- Web Services Orchestrated -->
<wss:dynamic-wsdl id="AppServicesV1" portTypeName="AppServicesV1Port" locationUri="/v1/appws" targetNamespace="http://www.yes.my/appservices">
<wss:xsd location="/WEB-INF/xsd/appservicesv1.xsd"/>
</wss:dynamic-wsdl>
在生成的wsdl中,ServiceExceptionFault作为操作生成。不确定会出现什么问题:
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:operation name="ServiceException" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:operation soapAction="" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:fault name="ServiceExceptionFault" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:fault name="ServiceExceptionFault" use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="AppPurchaseAddon" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:operation soapAction="" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
<wsdl:input name="AppPurchaseAddonRequest" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:input>
<wsdl:output name="AppPurchaseAddonResponse" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:output>
</wsdl:operation>