Announcement Announcement Module
Collapse
No announcement yet.
MTOM/XOP webservices annotations not working!!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MTOM/XOP webservices annotations not working!!!

    Dear team,

    The below same configuration is working fine in without MTOM. While enabled mtom from server side and soupui(type=XOP) the same not working. Please find below details configuration for your ref.

    Code:
    Spring version:  3.1
    Webservices  version: spring-ws-core-2.0.0.RELEASE.jar
    
    WSDL FILE:
      <xsd:element name="xmlStringData" type="xsd:string" /> 
      <xsd:element name="fileAttach" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream" /> 
    
    
    Endpint maping:
    @BindingType(value = SOAPBinding.SOAP11HTTP_MTOM_BINDING)
    @MTOM(enabled=true, threshold=2048)
    @Endpoint
    public class xxxxxxxxxxxxxServiceEndpoint{
    }
    
    Pojo:
    @XmlElement(namespace="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    @XmlMimeType("application/octet-stream")
    private DataHandler fileAttach;
    
    webservice xml file:
    <?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:p="http://www.springframework.org/schema/p"
    		xmlns:context="http://www.springframework.org/schema/context"
    		xmlns:jee="http://www.springframework.org/schema/jee"
    		xmlns:tx="http://www.springframework.org/schema/tx"
    		xmlns:sws="http://www.springframework.org/schema/web-services"
    		xsi:schemaLocation="http://www.springframework.org/schema/beans
    							http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    							http://www.springframework.org/schema/web-services
    							http://www.springframework.org/schema/web-services/web-services-2.0.xsd
    							http://www.springframework.org/schema/context
    							http://www.springframework.org/schema/context/spring-context-3.0.xsd
    							http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
    			                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    					
    
    
    	<context:component-scan base-package="com.xxxxxxxxxxxxxxxxxxxxx"/>
    	<sws:annotation-driven />
    Thanks,
    selva

  • #2
    Why should those (BindingType and MTOM) annotations be processed? You are using a Spring-WS endpoint nog a jax-ws endpoint...

    The endpoint doesn't need to do anything special, you need to tell the marshaller that MTOM is enabled so that attachments are processed. I suggest you take a look at the Spring-WS samples which included a MTOM sample.

    Comment


    • #3
      Thanks for quick reply.

      I have gone through the sample webservices which is given without annotation. But I am trying to use the annotation for MTOM. Please advice.

      Comment


      • #4
        There are NO Spring-WS annotations to enable MTOM... You have to configure the marshaller to support MTOM (as explained in my previous post and in the sample).

        Comment


        • #5
          Fine... Now i got your points... when can I expect MTOM on spring-WS annotations release?

          The below xml configuration used for mtom on spring-ws. The same also implemented and tested in my code. My value tag i have given my root package. But doesn't work for MTOM.

          <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
          <property name="packagesToScan" value="xxxxxxxxxxxxxxxxxxxxxx"/>
          <property name="mtomEnabled" value="true"/>
          </bean>


          And my pojo class should like this...


          @XmlRootElement(
          name="xxxxxxxxxxRequest",
          namespace="xxxxxxxxxxxxxxxxxxx")
          @XmlAccessorType(XmlAccessType.FIELD)
          @XmlType
          public class xxxxxxxxxxxxxRequest {
          @XmlElement(namespace="xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
          @XmlMimeType("application/octet-stream")
          private DataHandler fileAttach;


          }

          Comment


          • #6
            Please use [ code][/code ] tags when posting code, that way it remains readable...

            Why would there be a need for an annotation? YOu need to switch it on on the marshaller that is all tehre is.

            Post your configuration (make sure you have hooked up the marshaller with your annotation-driven tag, only adding the marshaller isn't doing anything).

            Comment


            • #7
              Sorry for the missed code tag.

              Why? means...If annotations enabled in MTOM spring-webservices no need write any configuration xml just plugin to @MTOM tag on endpoints.... .

              The below code configuration in my xml file....

              Code:
              <?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:context="http://www.springframework.org/schema/context"
              xmlns:jee="http://www.springframework.org/schema/jee"
              xmlns:tx="http://www.springframework.org/schema/tx"
              xmlns:sws="http://www.springframework.org/schema/web-services"
              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/context
              http://www.springframework.org/schem...ontext-3.0.xsd
              http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-3.0.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
              
              
              
              <context:component-scan base-package="xxxxxxxxxxxxxxxxxxxxxxxxxx"/>
              <sws:annotation-driven />
              
              
              <contextroperty-placeholder location="file:/opt/IBM/WebSphere/AppServer/profiles/commonconfig/config.properties"/>
              
              <jee:jndi-lookup id="dataSource" jndi-name="${jndiName}"/>
              
              <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager"
              p:dataSource-ref="dataSource"/>
              
              
              <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping"/>
              
              
              <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
              <property name="packagesToScan" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
              <property name="mtomEnabled" value="true"/>
              </bean>
              
              <bean class="org.springframework.ws.server.endpoint.adap ter.DefaultMethodEndpointAdapter">
              <property name="methodArgumentResolvers" ref="methodProcessor"/>
              <property name="methodReturnValueHandlers" ref="methodProcessor"/>
              </bean>
              
              <bean id="methodProcessor" class="org.springframework.ws.server.endpoint.adap ter.method.MarshallingPayloadMethodProcessor">
              <constructor-arg ref="marshaller"/>
              </bean>
              
              <bean id="xxxxxxxxService" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition" lazy-init="true">
              <property name="schemaCollection">
              <bean class="org.springframework.xml.xsd.commons.Commons XsdSchemaCollection">
              <property name="inline" value="true" />
              <property name="xsds">
              <list>
              <value>WEB-INF/schemas/xxxxxservice.xsd</value>
              </list>
              </property>
              </bean>
              </property>
              <property name="portTypeName" value="xxxxxService"/>
              <property name="serviceName" value="xxxxxxxService" />
              <property name="locationUri" value="/endpoints"/>
              </bean>
              
              This my servicesImpl class:
              
              try {
              DataHandler dataHandler = request.getFileAttach();
              InputStream inStr = dataHandler.getInputStream();
              int size = inStr.available();
              byte[] data = new byte[size];
              
              System.out.println("sssssss----datadata---ssssssssssssssssssss=========>"+data.length);
              Do you want to any other config?

              Comment


              • #8
                I strongly suggest you start to read the reference guide and get an understanding how things work.

                Code:
                <?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:context="http://www.springframework.org/schema/context"
                xmlns:jee="http://www.springframework.org/schema/jee"
                xmlns:tx="http://www.springframework.org/schema/tx"
                xmlns:sws="http://www.springframework.org/schema/web-services"
                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/context
                http://www.springframework.org/schem...ontext-3.0.xsd
                http://www.springframework.org/schema/jee http://www.springframework.org/schem...ng-jee-3.0.xsd
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
                
                
                
                <context:component-scan base-package="xxxxxxxxxxxxxxxxxxxxxxxxxx"/>
                <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
                
                <contextroperty-placeholder location="file:/opt/IBM/WebSphere/AppServer/profiles/commonconfig/config.properties"/>
                
                <jee:jndi-lookup id="dataSource" jndi-name="${jndiName}"/>
                
                <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="dataSource"/>
                
                <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
                	<property name="packagesToScan" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
                	<property name="mtomEnabled" value="true"/>
                </bean>
                You don't need the other stuff as that is already registered by the annotation-driven tag...

                Comment


                • #9
                  Thanks for your information. As you suggested i have tested, but since MTOM is not working. Please find the below configuration for your ref.

                  Code:
                  XML File:
                  
                  <context:component-scan base-package="com.abc"/>
                      <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
                  	
                  	
                      <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                          <property name="packagesToScan" value="com.abc"/>
                          <property name="mtomEnabled" value="true"/>
                      </bean>
                  
                  ServiceImpl:
                  
                  public TicketStatus getTicketDetailsxxxxxxTicketRequest request) throws BusinessException {		
                  		String ticketInfo=request.getXmlStringData();
                  		try {
                  			DataHandler dataHandler = request.getFileAttach();				
                  			InputStream inStr = dataHandler.getInputStream();
                              int size = inStr.available();
                              byte[] data = new byte[size];
                  	
                  			System.out.println("sssssss----datadata---ssssssssssssssssssss=========>"+data.length);
                  		
                  }
                  when to use "packagesToScan" or contextPath?

                  I am getting null in DataHandler. Kindly advice the same.

                  Thanks,
                  selva

                  Comment


                  • #10
                    Please use multiple code blocks instead of putting everything in a single one, it is confusing...

                    I suggest you enable debug (or even trace) logging for Spring-WS (setting org.springframework.ws to DEBUG or TRACE) and see what is happening. Judging from what is happening I think you run into this problem.

                    Comment


                    • #11
                      Dear Marten Deinum,

                      Please find below config files for your reference.

                      Code:
                      Server Startup code:
                      20:13:43,273 INFO  [Jaxb2Marshaller] Creating JAXBContext with classes to be bound [class com.xx.xxservices.services.bindservice.xxBTicketRequest,class com.xx.xxservices.services.bindservice.xxTicketResponse]
                      20:13:44,398 INFO  [SaajSoapMessageFactory] Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
                      Code:
                      XML FILE CONFIG:
                      <context:component-scan base-package="xxxxxxxxxxx"/>
                          <sws:annotation-driven marshaller="marshaller" unmarshaller="marshaller"/>
                      	
                      	
                      	<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                          <property name="classesToBeBound">
                              <list>
                                  <value>com.xxx.xxxxticketservices.services.bindservice.xxxxxTicketRequest</value>
                                  <value>com.xx.xxxxticketservices.services.bindservice.xxxxxTicketResponse</value>
                              </list>
                          </property>
                             <property name="mtomEnabled" value="true"/>
                      </bean>
                      Code:
                      SOAPUI REQUEST:
                      
                       <cms:fileAttach><inc:Include href="cid:Integration.pdf" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></cms:fileAttach>
                            </cms:CMSINBTicketRequest>
                         </soapenv:Body>
                      </soapenv:Envelope>
                      ------=_Part_15_31207576.1370443502484
                      Content-Type: application/octet-stream; name=Integration.pdf
                      Content-Transfer-Encoding: binary
                      Content-ID: <Integration.pdf>
                      Content-Disposition: attachment; name="Integration.pdf"; filename="Integration.pdf"
                      Everything is working fine and run successfully. Since MTOM issues is persistent. Please advice the same.

                      Thanks,
                      selva

                      Comment


                      • #12
                        I posted a link to a blog which shows you how to solve your problem, it also explains why the annotation-driven tag isn't going to help you here.

                        Comment

                        Working...
                        X