Привет, я использую веб-сервис Spring. Вот как выглядит мой xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws"
targetNamespace="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="abcPortalTokenDetailsRequest">
<xs:complexType>
<xs:annotation>
<xs:documentation>The data structure required to get token details</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="token" type="token3rdParty"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="abcPortalTokenDetailsResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="tokenDetails" type="TokenDetailsType" />
<xs:element name="result" type="resultStructure"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="token3rdParty">
<xs:restriction base="xs:token">
<xs:minLength value="1"></xs:minLength>
<xs:maxLength value="60"></xs:maxLength>
<xs:pattern value="([A-Za-z0-9]+)" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="TokenDetailsType">
<xs:annotation>
<xs:documentation>token details</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="sNumber" type="SNumberType"/>
<xs:element name="sId" type="SIdType"/>
<xs:element name="sName" type="SNameType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="SNumberType">
<xs:restriction base="xs:string">
<xs:minLength value="1"></xs:minLength>
<xs:maxLength value="60"></xs:maxLength>
<xs:pattern value="([A-Za-z0-9]+)" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SIdType">
<xs:restriction base="xs:string">
<xs:minLength value="1"></xs:minLength>
<xs:maxLength value="2"></xs:maxLength>
<xs:pattern value="([A-Za-z]+)" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SNameType">
<xs:restriction base="xs:string">
<xs:minLength value="1"></xs:minLength>
<xs:maxLength value="128"></xs:maxLength>
<xs:pattern value="([A-Za-z0-9]+)" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="resultStructure">
<xs:sequence>
<xs:element name="resultCode" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>The result code indicates the outcome of the available list for request.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="OK"/>
<xs:enumeration value="INVALID"/>
<xs:enumeration value="ERROR"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="resultMessage" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>The associated message for this result</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Вот конечная точка
@Endpoint
public class abcPortalTokenDetailsEndpoint {
private IabcPortalManager abcPortalManager;
private static final Logger logger = Logger.getLogger(abcPortalTokenDetailsEndpoint.class);
public void setAbcPortalManager(IabcPortalManager abcPortalManager) {
this.abcPortalManager = abcPortalManager;
}
@PayloadRoot(localPart= "AbcPortalTokenDetailsRequest", namespace="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws")
public abcPortalTokenDetailsResponse doit(abcPortalTokenDetailsRequest request){
abcPortalTokenDetailsResponse response = new abcPortalTokenDetailsResponse();
// check that the token is currently valid
String token = request.getToken().trim();
String resultCode = "ERROR", resultMessage = "Internal error occured - valid response could not be generated";
boolean okResult = true, valid = false;
TAuth tp = null;
Integer sId = 0;
String sName = "";
String errorMsg = null;
try {
//validate token
if (token != null) {
resultCode = "OK";
resultMessage = "Valid session";
} else {
resultCode = "INVALID";
resultMessage = "No record of user being logged in";
okResult = false;
}
} catch (DataAccessException ex) {
String fmtStr = "Could not determine whether end user token (%s) is valid.\n %s";
String errMsg = String.format(fmtStr, token, ex.getMessage());
okResult = false;
logger.error(errMsg);
assert(false) : errMsg;
}
if(okResult){
if(logger.isDebugEnabled()){
logger.debug("abcPortalTokenDetailsResponse Authenticate user" );
}
tp = abcPortalManager.getTpAuth(token);
if(logger.isDebugEnabled()){
if(tp != null){
if (tp.getSId()!= null){
sName = "ct"; abcPortalManager.getSName(tp.getSId());
}
} else {
logger.debug("abcPortalTokenDetailsResponse tparty details not found");
}
}
valid = true;
}
TokenDetailsType tokenDetailsPart = constructResponseTokenDetailsPart(valid, okResult, tp, sName);
response.setTokenDetails(tokenDetailsPart);
ResultStructure resultPart = constructResponseResultPart(valid, okResult, errorMsg);
response.setResult(resultPart);
return response;
}
private TokenDetailsType constructResponseTokenDetailsPart(
boolean valid, boolean okResult, TAuth tp,String sName) {
TokenDetailsType tdt = null;
if (valid && okResult) {
tdt = new TokenDetailsType();
tdt.setSId(tp.getSId());
tdt.setSNumber(tp.getSNumber);
tdt.setSName(sName);
}
return tdt;
}
/**
*
* @param response
* @param okResult
* void
*
*/
private ResultStructure constructResponseResultPart(
boolean valid, boolean okResult, String errorMessage) {
// Determine result part of response
String resultCode, resultMessage;
if (okResult) {
resultCode = (valid) ? "OK" : "INVALID";
resultMessage = (valid) ? "Successfull query" : "User not authorised";
} else {
resultCode = "ERROR";
resultMessage = "Valid response could not be generated: " + errorMessage;
}
ResultStructure resp_result = new ResultStructure();
resp_result.setResultCode(resultCode);
resp_result.setResultMessage(resultMessage);
return resp_result;
}
}
когда я пытаюсь протестировать веб-сервис с помощью SoapUI, почему в моем проекте ответ имеет несколько пространств имен различных веб-сервисов ??? я ожидаю, что только abcportaltokendetailsws, а не другие службы, такие как abcportalloginstatusws, abcportallogoutws не уверены, почему это отображается?
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns10:abcPortalTokenDetailsResponse
xmlns:ns10="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws"
xmlns:ns2="http://www.test-software.co.uk/abcportal/schema/abcportalloginstatusws" xmlns:ns4="http://www.test-software.co.uk/abcportal/schema/abcportallpaymentws" xmlns:ns5="http://www.test-software.co.uk/abcportal/schema/abcportallogoutws" xmlns:ns6="http://www.test-software.co.uk/abcportal/schema/abcportalfundservicews" xmlns:ns7="http://www.test-software.co.uk/abcportal/schema/abcportalpayservicews"
<ns10:tokenDetails>
<ns10:sNumber>43454</ns10:sNumber>
<ns10:sId/>
<ns10:sName>Bridge Market</ns10:sName>
</ns10:tokenDetails>
<ns10:result>
<ns10:resultCode>OK</ns10:resultCode>
<ns10:resultMessage>Successfull query</ns10:resultMessage>
</ns10:result>
</ns10:abcPortalTokenDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>