这是我用来从中生成Java类的XSD(使用jaxb2-maven-plugin):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://b2b.adx.com" targetNamespace="http://b2b.adx.com" elementFormDefault="qualified">
<xs:element name="CheckRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Authentication" type="tns:AuthenticationType"/>
<xs:element name="Request" type="tns:RequestType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CheckResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Message" type="tns:MessageType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="AuthenticationType">
<xs:sequence>
<xs:element name="username" type="xs:string"/>
<xs:element name="password" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RequestType">
<xs:sequence>
<xs:element name="countryID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MessageType">
<xs:sequence>
<xs:element name="messageCode" type="xs:string"/>
<xs:element name="messageText" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
我使用这些生成的类来使用Spring创建SOAP服务。响应如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:CheckVinResponse xmlns:ns2="http://b2b.adx.com">
<ns2:Message>
<ns2:messageCode>2000</ns2:messageCode>
<ns2:messageText>A message text</ns2:messageText>
</ns2:Message>
</ns2:CheckVinResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我需要回复如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:AudaSmartCheckWSDL">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<urn:CheckVinResponse>
<urn:Message>
<urn:messageCode>2000</ns2:messageCode>
<urn:messageText>A message text</ns2:messageText>
</urn:Message>
</urn:CheckVinResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
请问如何实现?我可以更改XSD或SOAP服务代码,但不能更改响应规范。