Announcement Announcement Module
Collapse
No announcement yet.
NULL request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NULL request

    I am getting a null value in the request: here's my request

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://schemas.mypublisher.com/Authentication">
    <soapenv:Header/>
    <soapenv:Body>
    <aut:authenticationRequest>
    <aut:security>
    <aut:username>sanjeev</aut:username>
    <autassword>sanjeev</autassword>
    </aut:security>
    </aut:authenticationRequest>
    </soapenv:Body>
    </soapenv:Envelope>

    I get a null in when i do request.getValue().getSecurity().getUsername();

    Help me on this:

    related files are:


    xsd:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://schemas.mypublisher.com/Authentication"
    xmlns:authentication="http://schemas.mypublisher.com/Authentication" elementFormDefault="qualified">

    <xsd:complexType name="AuthenticationType">
    <xsd:sequence>
    <xsd:element name="security" type="authentication:SecurityType"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="SecurityType">
    <xsd:sequence>
    <xsd:element name="username" type="xsd:string"/>
    <xsd:element name="password" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="AuthenticationResponseType">
    <xsd:sequence>
    <xsd:element name="isLoggedIn" type="xsd:boolean" />
    </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="authenticationRequest" type="authentication:AuthenticationType"/>
    <xsd:element name="authenticationResponse" type="authentication:AuthenticationResponseType"/>
    </xsd:schema>

  • #2
    *-webservice.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/p"
    xmlns:mpws="http://www.springframework.org/schema/web-services"
    xmlns:oxm="http://www.springframework.org/schema/oxm"
    xsi:schemaLocation=
    "http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/web-services
    http://www.springframework.org/schem...rvices-2.0.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">

    <description>
    This web application context contains Spring-WS beans. The beans defined in this context are automatically
    detected by Spring-WS, similar to the way Controllers are picked up in Spring Web MVC.
    </description>

    <!-- uses annotations to map XML requests to endpoint methods -->

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping"/>


    <mpws:dynamic-wsdl id="userLogin" portTypeName="UserLogin" locationUri="/services">
    <mpws:xsd location="/WEB-INF/xsd/login.xsd"/>
    </mpws:dynamic-wsdl>
    <bean id="loginEndpoint" class="com.mypublisher.common.login.LoginEndpoint" autowire="byName" />
    <bean id="loginService" class="com.mypublisher.common.login.LoginServiceIm pl"/>

    <mpws:dynamic-wsdl id="authentication" portTypeName="UserAuthentication" locationUri="/services">
    <mpws:xsd location="/WEB-INF/xml-schema/Authentication.xsd"/>
    </mpws:dynamic-wsdl>
    <bean id="authenticationEndpoint" class="com.mypublisher.services.authentication.Aut henticationEndpoint" autowire="byName" />
    <bean id="authenticationService" class="com.mypublisher.services.authentication.Aut henticationServiceImpl"/>



    <!-- JAXB2 object to xml mappings. -->
    <oxm:jaxb2-marshaller id="jaxbmarshaller" contextPath="com.mypublisher.schema" />
    <oxm:jaxb2-marshaller id="jaxbunmarshaller" contextPath="com.mypublisher.schema" />

    <!-- Normally we use the GenericMarshallingMethodEndpointAdapter however if you read the Spring WS 2.0 API for this adapter:
    "Deprecated. as of Spring Web Services 2.0, in favor of DefaultMethodEndpointAdapter and MarshallingPayloadMethodProcessor."
    See http://static.springsource.org/sprin...ntAdapter.html

    So we have to implement using the recommended implementation. The advantage of these two classes is that
    we have a pluggable adapter. For more info, check the Spring WS 2.0 API and its source code.
    -->
    <bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adap ter.method.MarshallingPayloadMethodProcessor">
    <constructor-arg ref="jaxbmarshaller"/>
    <constructor-arg ref="jaxbunmarshaller"/>
    </bean>

    <bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adap ter.DefaultMethodEndpointAdapter">
    <property name="methodArgumentResolvers">
    <list>
    <ref bean="marshallingPayloadMethodProcessor"/>
    </list>
    </property>
    <property name="methodReturnValueHandlers">
    <list>
    <ref bean="marshallingPayloadMethodProcessor"/>
    </list>
    </property>
    </bean>


    <mpws:interceptors>
    <bean class="org.springframework.ws.soap.server.endpoint .interceptor.PayloadValidatingInterceptor">
    <description>
    This interceptor validates both incoming and outgoing message contents according to the '*.xsd' XML
    Schema file.
    </description>
    <property name="Schema" value="/WEB-INF/xml-schema/Authentication.xsd"/>
    <property name="validateRequest" value="true"/>
    <property name="validateResponse" value="true"/>
    </bean>
    <bean class="org.springframework.ws.server.endpoint.inte rceptor.PayloadLoggingInterceptor">
    <description>
    This interceptor logs the message payload.
    </description>
    </bean>
    </mpws:interceptors>


    </beans>

    Comment


    • #3
      the endpoint class

      package com.mypublisher.services.authentication;

      import javax.xml.bind.JAXBElement;

      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.springframework.beans.factory.annotation.Autow ired;
      import org.springframework.ws.server.endpoint.annotation. Endpoint;
      import org.springframework.ws.server.endpoint.annotation. PayloadRoot;
      import org.springframework.ws.server.endpoint.annotation. RequestPayload;
      import org.springframework.ws.server.endpoint.annotation. ResponsePayload;

      import com.mypublisher.schema.AuthenticationResponseType;
      import com.mypublisher.schema.AuthenticationType;
      import com.mypublisher.schema.ObjectFactory;

      @Endpoint
      public class AuthenticationEndpoint {


      private AuthenticationService authenticationService;
      private final ObjectFactory objectFactory = new ObjectFactory();
      protected final Log logger = LogFactory.getLog(getClass());

      /**
      * Namespace of both request and response.
      */
      public static final String NAMESPACE_URI = "http://schemas.mypublisher.com/Authentication";

      /**
      * The local name of the expected request.
      */
      public static final String ECHO_REQUEST_LOCAL_NAME = "authenticationRequest";

      /**
      * The local name of the created response.
      */
      public static final String ECHO_RESPONSE_LOCAL_NAME = "authenticationResponse";



      @PayloadRoot (localPart=ECHO_REQUEST_LOCAL_NAME, namespace=NAMESPACE_URI)
      @ResponsePayload
      public JAXBElement<AuthenticationResponseType> authenticateUser(@RequestPayload JAXBElement<AuthenticationType> request) throws Exception {

      if (logger.isDebugEnabled()) {
      logger.debug("AuthenticationRequest Recieved for user with username "+ request.getValue().getSecurity().getUsername());
      }


      AuthenticationResponseType authenticationResponse = new AuthenticationResponseType();
      boolean isLoggedIn = authenticationService.authenticateUser(request.get Value());
      authenticationResponse.setIsLoggedIn(isLoggedIn);

      logger.info("Returning the response.");
      return objectFactory.createAuthenticationResponse(authent icationResponse);

      }


      @Autowired
      public void setAuthenticationService(AuthenticationService authenticationService) {
      this.authenticationService = authenticationService;
      }

      }

      Comment


      • #4
        I am getting a null request.

        Am I doing something wrong here?


        here is the request and repsonse stacktrace:

        2011-03-21 18:02:11,372 [http-8080-2] DEBUG org.springframework.ws.server.MessageDispatcher - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.Pay loadRootAnnotationMethodEndpointMapping@49d159e4] maps request to endpoint [public javax.xml.bind.JAXBElement<com.mypublisher.schema. AuthenticationResponseType> com.mypublisher.services.authentication.Authentica tionEndpoint.authenticateUser(javax.xml.bind.JAXBE lement<com.mypublisher.schema.AuthenticationType>) throws java.lang.Exception]
        2011-03-21 18:02:11,373 [http-8080-2] DEBUG org.springframework.ws.soap.server.endpoint.interc eptor.PayloadValidatingInterceptor - Request message validated
        2011-03-21 18:02:11,373 [http-8080-2] DEBUG org.springframework.ws.server.endpoint.interceptor .PayloadLoggingInterceptor - Request: <aut:authenticationRequest xmlns:aut="http://schemas.mypublisher.com/Authentication">
        <aut:security>
        <aut:username>sanjeev</aut:username>
        <autassword>sanjeev</autassword>
        </aut:security>
        </aut:authenticationRequest>
        2011-03-21 18:02:11,373 [http-8080-2] DEBUG org.springframework.ws.server.MessageDispatcher - Testing endpoint adapter [org.springframework.ws.server.endpoint.adapter.Def aultMethodEndpointAdapter@5ac0fee0]
        2011-03-21 18:02:11,374 [http-8080-2] DEBUG org.springframework.ws.server.endpoint.adapter.met hod.MarshallingPayloadMethodProcessor - Unmarshalled payload request to [javax.xml.bind.JAXBElement@1436eb76]
        2011-03-21 18:02:11,374 [http-8080-2] DEBUG org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'authenticationEndpoint'
        2011-03-21 18:02:14,830 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerExceptionResolver - Resolving exception from handler [org.springframework.ws.server.MessageDispatcher@19 ba67ec]: java.lang.NullPointerException
        2011-03-21 18:02:14,831 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.annotation.Res ponseStatusExceptionResolver - Resolving exception from handler [org.springframework.ws.server.MessageDispatcher@19 ba67ec]: java.lang.NullPointerException
        2011-03-21 18:02:14,831 [http-8080-2] DEBUG org.springframework.web.servlet.mvc.support.Defaul tHandlerExceptionResolver - Resolving exception from handler [org.springframework.ws.server.MessageDispatcher@19 ba67ec]: java.lang.NullPointerException
        2011-03-21 18:02:14,831 [http-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Could not complete request
        java.lang.NullPointerException
        at com.mypublisher.services.authentication.Authentica tionEndpoint.authenticateUser(AuthenticationEndpoi nt.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.ws.server.endpoint.MethodEndpo int.invoke(MethodEndpoint.java:132)
        at org.springframework.ws.server.endpoint.adapter.Def aultMethodEndpointAdapter.invokeInternal(DefaultMe thodEndpointAdapter.java:229)
        at org.springframework.ws.server.endpoint.adapter.Abs tractMethodEndpointAdapter.invoke(AbstractMethodEn dpointAdapter.java:53)
        at org.springframework.ws.server.MessageDispatcher.di spatch(MessageDispatcher.java:230)
        at org.springframework.ws.server.MessageDispatcher.re ceive(MessageDispatcher.java:172)
        at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:88)
        at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
        at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
        at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
        at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invok

        Comment

        Working...
        X