Announcement Announcement Module
Collapse
No announcement yet.
Exposing a WSDL when not using MessageDispatcherServlet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exposing a WSDL when not using MessageDispatcherServlet

    I have made a transition from using a MessageDispatcherServlet to using a normal DispatcherServlet to avoid having duplicate code for handling hibernate sessions in the web service compared with the rest of the application. I followed the instructions in the reference documentation under
    "5.3.2. Wiring up Spring-WS in a DispatcherServlet"

    The webservice works fine but I'm having trouble exposing the wsdl without the automated support in MessageDispatcherServlet.

    Any ideas would be greatly appreciated!

    Thanks
    /Ola

    Code:
    	<bean id="customHandlerMapping" parent="handlerMapping">
    		<property name="order" value="0"/>
    		<property name="mappings">
    			<props>
    				...
    				<prop key="/modelPublicationServletMapping/*">messageDispatcher</prop>
    			</props>
    		</property>
    	</bean>
    
    
    	<bean class="org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter">
    		<property name="messageFactory" ref="messageFactory"/>
    	</bean>
    	
    	<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
    
    	<bean id="messageDispatcher" class="org.springframework.ws.soap.server.SoapMessageDispatcher">
    		<property name="endpointMappings">
    			<ref local="payloadMapping"/>
    		</property>
    	</bean>
    
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
    
    	....
    
    	<bean id="publishModelEndpoint" class="com.tacton.tcsite.quickshare.webservices.PublishModelWSEndPoint">
    		<property name="organizationService" ref="organizationService"/>
    		<property name="userService" ref="userService"/>
    		<property name="userGroupService" ref="userGroupService"/>
    		<property name="productService" ref="productService"/>
    		<property name="modelFileService" ref="modelFileService"/>
    		<property name="orderService">
    			<bean class="com.tacton.tcsite.order.services.OrderService">
    				<property name="orderDao" ref="orderDao" />
    			</bean>
    		</property>
    		<property name="resourceService" ref="resourceService"/>
    	</bean>
    
    	<bean id="wsdlName" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
    		<property name="schema" ref="schema"/>
    		<property name="portTypeName" value="ModelPublicationService"/>
    		<property name="locationUri" value="/modelPublicationServletMapping/"/>
    	</bean>
    	<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    		<property name="xsd" value="/WEB-INF/publishModel.xsd"/>
    	</bean>
    
    	<bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    		<property name="mappings">
    			<props>
    				<prop key="{modelPublicationNamespace}ModelPublicationRequest">publishModelEndpoint</prop>
    			</props>
    		</property>
    		<property name="interceptors">
    			<list>
    				<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
    					<property name="loggerName" value="tc" />
    				</bean>
    			</list>
    		</property>
    	</bean>

  • #2
    solved it!

    I have found a solution exposing the wsdl via a custom controller, see below

    Code:
    import com.tacton.tcsite.utils.BaseController;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter;
    import org.springframework.ws.wsdl.WsdlDefinition;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class WsdlExposingController extends BaseController {
    
    	WsdlDefinition wsdlDefinition;
    
    	public ModelAndView defaultAction(HttpServletRequest request,
    									  HttpServletResponse response) throws Exception {
    		WsdlDefinitionHandlerAdapter wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter();
    		wsdlDefinitionHandlerAdapter.handle(request, response, wsdlDefinition);
    		return null;
        }
    
    	public void setWsdlDefinition(WsdlDefinition wsdlDefinition) {
    		this.wsdlDefinition = wsdlDefinition;
    	}
    }

    Comment

    Working...
    X