Spring Web服务响应具有不同Web服务的多个命名空间(java)

发布于 2024-10-11 00:28:11 字数 10237 浏览 5 评论 0原文

您好,我正在使用 Spring Web 服务 这是我的 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 测试 Web 服务时的 为什么响应在我的项目中具有不同 Web 服务的多个命名空间???我只期待 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>

Hi I am using Spring web service Here is how my xsd looks

 <?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>

Here is the Endpoint

@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;     

    }



}

when i try to test the webservice using SoapUI why response has multiple namespace of different webservices within my project??? i am expecting just abcportaltokendetailsws and not other services like abcportalloginstatusws ,abcportallogoutws not sure why this is displayed?

  <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

那支青花 2024-10-18 00:28:11

这可以避免使用 Spring 2.5 和 spring-ws 1.5.9 abcPortalTokenDetailsEndpoint 可以扩展 MarshallingMethodEndpointAdapter。同样在配置文件中,如果我们为每个端点使用不同的 beanid 编组器,它也可以正常工作。我也在 Spring 3.0 和 spring-ws 1.5.9 中尝试了同样的事情,官方不支持它,它不能与多个 beanid marshaller 一起使用,它需要 bean id 中的单词 marshaller ???
例子
整个问题是使用带有“:”或“列表”的上下文路径(这会在响应中添加所有名称空间)

<oxm:jaxb2-marshaller id="marshaller" contextPath="com.abc.web.ws.login.status.schema:com.abc.web.ws.profile.schema:com.abc.web.ws.tokendetails.schema>

如果我们将上面的代码更改为如下,它在 Spring 2.5.6 中工作,而不是在 Spring 3.0 中工作,为什么???

<bean id="abcPortalTokenDetailsEndpoint" class="com.abc.web.ws.tokendetails.abcPortalTokenDetailsEndpoint">

        <property name="marshaller" ref="marshaller1"/>
        <property name="unmarshaller" ref="marshaller1"/>
    </bean>

 <bean id="abcPortalTrustedAccessLogInEndpoint" class="com.abc.web.ws.login.trustedaccess.abcPortalTrustedAccessLogInEndpoint">      

        <property name="marshaller" ref="marshaller2"/>
        <property name="unmarshaller" ref="marshaller2"/>
 </bean>

<bean id="abcPortalThirdPartyLogInEndpoint" class="com.abc.web.ws.login.thirdparty.abcPortalThirdPartyLogInEndpoint">

        <property name="marshaller" ref="marshaller"/>
        <property name="unmarshaller" ref="marshaller"/>
    </bean>

    <bean id="marshaller1" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
          <property name="contextPath" value="com.abc.web.ws.tokendetails.schema"/>                     
        </bean>

         <bean id="marshaller2" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
          <property name="contextPath" value="com.abc.web.ws.login.trustedaccess.schema"/>                      
        </bean>

        <bean id="marshaller3" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">        
            <property name="contextPath" value="com.abc.web.ws.login.thirdparty.schema"/>       
        </bean>









public class abcPortalTokenDetailsEndpoint extends MarshallingMethodEndpointAdapter{

    private IabcPortalManager abcPortalManager;

    private static final Logger logger = Logger.getLogger(abcPortalTokenDetailsEndpoint.class);

        public void setAbcPortalManager(IabcPortalManager abcPortalManager) {
        this.abcPortalManager = abcPortalManager;
    }




   public abcPortalTokenDetailsResponse handleabcPortalTokenDetailsRequest(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;
    }

This is possible to avoid using Spring 2.5 along with spring-ws 1.5.9 abcPortalTokenDetailsEndpoint can extend MarshallingMethodEndpointAdapter. Also in the config file if we have different beanid marshallers for each end points it works fine. I also tried the same thing in Spring 3.0 and spring-ws 1.5.9 officially not supported , it does not work with multiple beanid marshaller, it needs the word marshaller in the bean id ???
example
the whole problem is using contextpath with ":" or "list" (this adds all the namesapce in the response)

<oxm:jaxb2-marshaller id="marshaller" contextPath="com.abc.web.ws.login.status.schema:com.abc.web.ws.profile.schema:com.abc.web.ws.tokendetails.schema>

if we change the above code to as following it works in Spring 2.5.6 not spring 3.0 why???

<bean id="abcPortalTokenDetailsEndpoint" class="com.abc.web.ws.tokendetails.abcPortalTokenDetailsEndpoint">

        <property name="marshaller" ref="marshaller1"/>
        <property name="unmarshaller" ref="marshaller1"/>
    </bean>

 <bean id="abcPortalTrustedAccessLogInEndpoint" class="com.abc.web.ws.login.trustedaccess.abcPortalTrustedAccessLogInEndpoint">      

        <property name="marshaller" ref="marshaller2"/>
        <property name="unmarshaller" ref="marshaller2"/>
 </bean>

<bean id="abcPortalThirdPartyLogInEndpoint" class="com.abc.web.ws.login.thirdparty.abcPortalThirdPartyLogInEndpoint">

        <property name="marshaller" ref="marshaller"/>
        <property name="unmarshaller" ref="marshaller"/>
    </bean>

    <bean id="marshaller1" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
          <property name="contextPath" value="com.abc.web.ws.tokendetails.schema"/>                     
        </bean>

         <bean id="marshaller2" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
          <property name="contextPath" value="com.abc.web.ws.login.trustedaccess.schema"/>                      
        </bean>

        <bean id="marshaller3" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">        
            <property name="contextPath" value="com.abc.web.ws.login.thirdparty.schema"/>       
        </bean>









public class abcPortalTokenDetailsEndpoint extends MarshallingMethodEndpointAdapter{

    private IabcPortalManager abcPortalManager;

    private static final Logger logger = Logger.getLogger(abcPortalTokenDetailsEndpoint.class);

        public void setAbcPortalManager(IabcPortalManager abcPortalManager) {
        this.abcPortalManager = abcPortalManager;
    }




   public abcPortalTokenDetailsResponse handleabcPortalTokenDetailsRequest(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;
    }
℡Ms空城旧梦 2024-10-18 00:28:11

不需要单独的编组器。可以通过将 Endpoint 中的 Response 方法注释为 @ResponsePayload 来解决。
前任:

@PayloadRoot(localPart= "AbcPortalTokenDetailsRequest", namespace="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws")
@ResponsePayload

public abcPortalTokenDetailsResponse doit(abcPortalTokenDetailsRequest request){

No need to have separate marshaller. Can be solved by having the Response method in your Endpoint annotated as @ResponsePayload.
Ex:

@PayloadRoot(localPart= "AbcPortalTokenDetailsRequest", namespace="http://www.test-software.co.uk/abcportal/schema/abcportaltokendetailsws")
@ResponsePayload

public abcPortalTokenDetailsResponse doit(abcPortalTokenDetailsRequest request){
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文