我正在使用注释将依赖于Weblogic 8(servicegen)的旧Web服务移动到JAX WS实现。我使用现有的WSDL和JAXB来生成数据对象(编组/解组)。但是,我注意到现在使用JAXWS生成的SOAP响应存在差异。我需要生成相同的响应,因为有超过900个客户端,并且不能要求他们修改他们的代码以使用新的响应模式。
现有的回复如下:
<env:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header/>
<env:Body>
<m:findAllCertInfoByOwnerResponse xmlns:m="http://uum.webservices.com">
<n1:result xsi:type="n2:ArrayOfWSCertInfo" xmlns:n1="http://uum.webservices.com" xmlns:n2="java:com.service.data">
<n2:WSCertInfo>
<n2:CPCreateDate> </n2:CPCreateDate>
<n2:CPExpireDate> </n2:CPExpireDate>
<n2:CPStatus> </n2:CPStatus>
<n2:PrevUniqueId>123456</n2:PrevUniqueId>
<n2:UniqueId></n2:UniqueId>
<n2:certID xsi:nil="true"/>
<n2:certStatus/>
<n2:endDate xsi:nil="true"/>
<n2:issuerDN> </n2:issuerDN>
<n2:owner></n2:owner>
<n2:profileName> </n2:profileName>
<n2:renewalStatus xsi:nil="true"/>
<n2:revokeReason/>
<n2:serialNo xsi:nil="true"/>
<n2:startDate xsi:nil="true"/>
<n2:subjectDN xsi:nil="true"/>
<n2:validCertificate>false</n2:validCertificate>
<n2:validEnrollment>true</n2:validEnrollment>
</n2:WSCertInfo>
</n1:result>
</m:findAllCertInfoByOwnerResponse>
</env:Body>
</env:Envelope>
新的JAX WS SOAP响应具有以下格式:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:findLatestCertInfoByOwnerResponse xmlns:ns3="java:com.service.data" xmlns:ns2="http://uum.webservices.com">
<result>
<ns2:result>
<ns3:WSCertInfo>
<ns3:CPCreateDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:CPExpireDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:CPStatus xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:PrevUniqueId>123456</ns3:PrevUniqueId>
<ns3:UniqueId xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:certID xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:certStatus xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:endDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:issuerDN xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:owner xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:profileName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:renewalStatus xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:revokeReason xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:serialNo xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:startDate xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:subjectDN xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns3:validCertificate>false</ns3:validCertificate>
<ns3:validEnrollment>false</ns3:validEnrollment>
</ns3:WSCertInfo>
</ns2:result>
</result>
</ns2:findLatestCertInfoByOwnerResponse>
</S:Body>
</S:Envelope>
JAXWS SOAP响应非常接近,除了以下内容:
如何将xsi:type和xmlns添加到属性?
我将包含示例类以显示已定义的Web注释。
提前感谢您的帮助!!!!!
Web Service类如下所示:
@WebService(
name = "UUMCertLocatorService",
serviceName = "UUMCertLocatorService",
portName = "UUMCertLocatorServicePort",
targetNamespace = "http://uum.webservices.com",
wsdlLocation = "UUMCertLocatorService.wsdl")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED,
style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL)
public class UUMCertLocatorServiceEndPoint {
@WebMethod(action="",operationName="findLatestCertInfoByOwner")
@WebResult(name="findLatestCertInfoByOwnerResponse",header=true,targetNamespace="java:com.service.data",partName="http://uum.webservices.com")
public FindAllCertInfoByOwnerResponse findAllCertInfoByOwner(
@WebParam(targetNamespace="http://uum.webservices.com",
partName="http://uum.webservices.com",
name="string")String uniqueID,
@WebParam(targetNamespace="http://uum.webservices.com",
partName="http://uum.webservices.com",
name="string0")String adminSessionSpec,
@WebParam(targetNamespace="http://uum.webservices.com",
partName="http://uum.webservices.com",
name="string1")String webKey) throws WSUUMException
{
LogHelper.debug(UUMCertLocatorServiceEndPoint.class, "Params: {} {} {} ", uniqueID,adminSessionSpec,webKey);
final ObjectFactory objectFactory = new ObjectFactory();
FindAllCertInfoByOwnerResponse response = objectFactory.createFindAllCertInfoByOwnerResponse();
WSCertInfo certinfo = objectFactory.createWSCertInfo();
certinfo.setBofaPrevUniqueId("123456");
ArrayOfWSCertInfo arraycert = objectFactory.createArrayOfWSCertInfo();
arraycert.getWSCertInfo().add(certinfo);
response.setResult(arraycert);
return response;
}
}