1 Reply Latest reply on Jun 5, 2007 9:10 AM by heiko.braun

    SWA / MTOM attachments

    sirigiris

      Hi All,
      I've deployed the samples provided by jbossws 1.2.0 on Jboss4.0.4GA and while trying to execute the SWA example, I'm getting the following exception. I came to know through forums that I need to enable MTOM endpoint. The MTOM service is also deployed on the server. Now to get the attachments example working what should I do?

      - Call invocation failed with unkown Exception
      org.jboss.ws.binding.BindingException: Mime type text/xml not allowed for parameter mimepart allowed types are [application/xml]
      at org.jboss.ws.binding.soap.SOAPBindingProvider.createAttachmentPart(SOAPBindingProvider.java:605)
      at org.jboss.ws.binding.soap.SOAPBindingProvider.bindRequestMessage(SOAPBindingProvider.java:118)
      at org.jboss.ws.binding.soap.SOAP11BindingProvider.bindRequestMessage(SOAP11BindingProvider.java:65)
      at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:645)
      at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
      at ws.jboss.org.samples.swa.AttachTest1.main(AttachTest1.java:108)
      Exception in thread "main" java.rmi.RemoteException: Call invocation failed: Mime type text/xml not allowed for parameter mimepart allowed types are [application/xml]; nested exception is:
      org.jboss.ws.binding.BindingException: Mime type text/xml not allowed for parameter mimepart allowed types are [application/xml]
      at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:718)
      at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
      at ws.jboss.org.samples.swa.AttachTest1.main(AttachTest1.java:108)

      As of now I'm running a standalone java program. Please find the code attached. Help is highly appreciated.

      ServiceFactory factory = ServiceFactory.newInstance();
      Service service = factory.createService(SERVICE_NAME);
      Call call = service.createCall();
      call.setOperationName(new QName(TARGET_NAMESPACE, rpcMethodName));
      call.addParameter("message", new QName(Constants.NS_SCHEMA_XSD, "string"), ParameterMode.IN);
      if (contentType.equals("application/xml"))
      call.addParameter("mimepart", Constants.TYPE_MIME_APPLICATION_XML, DataHandler.class, ParameterMode.IN);
      call.setReturnType(new QName(Constants.NS_SCHEMA_XSD, "string"));
      call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS); call.setTargetEndpointAddress(TARGET_ENDPOINT_ADDRESS);
      URL temp = new File("resources/jaxrpc/samples/swa/attach.xml").toURL();

      String strTempURL = temp.toString();
      strTempURL = strTempURL.substring(strTempURL.lastIndexOf("/"),strTempURL.length());
      URL url = new URL("http","10.2.154.75",8080,strTempURL);
      String value = (String)call.invoke(new Object[] {"application/xml" , new DataHandler(url)});
      System.out.println("Value ::"+ value);

      Regards,
      Sreedhar

        • 1. Re: SWA / MTOM attachments
          heiko.braun

          Sreedhar, MTOM and SwA are two diffrent things. Both deal with attachments but in different manner. Actually when talking about attachments you'll encounter SwA, SwARef and MTOM/XOP.

          SwA has interop issues which SwARef did solve and MTOM relieves the interposed SOAP processors from having to deal with resource consumption while processing messages in transit.

          However, looking at your detailed report (thanks, that simplifies things a lot) i can see two things:


          org.jboss.ws.binding.BindingException: Mime type text/xml not allowed for parameter mimepart allowed types are [application/xml]



          URL temp = new File("resources/jaxrpc/samples/swa/attach.xml").toURL();


          See first one states that the endpoint does only accept attachment of the type "application/octet-stream". Looking at your samples code in the second quote, you create a URL to a *.xml file. The JAF API will create a DataHandler instance with the content-type 'text/xml' from that, which then would be submitted.

          If you change the client to use the right content-type everything works fine. Please consult the JAF API for further information on this topic.