4 Replies Latest reply on Mar 12, 2007 5:30 PM by Lee Brackman

    How do I use MIME types other than text/xml

    Lee Brackman Newbie

      I am trying to use MTOM to send attachments. I am using wstools to generate all components from an endpoint. I successfully run a test with a text/xml type but I cannot use any others types including text/plain or application/octect. The following is my endpoint and config file:

      endpoint -

      public interface FileXferEndpoint extends Remote {

      public String sendPart(Long txId, Integer partNum, Long size, DataHandler data) throws RemoteException;
      }

      config file -


      <java-wsdl>


      <namespaces target-namespace="http://fileXfer.ws.synoran.com/"
      type-namespace="http://fileXfer.ws.synoran.com/types"/>

      <webservices servlet-link="FileXferWS"/>
      </java-wsdl>


      Environment:
      JBoss 4.0.5.GA
      Java 1.5(5.0)
      JbossWS 2.0

      I always get the following error:
      failed; nested exception is:
      [java] org.jboss.ws.core.jaxrpc.binding.BindingException: Mime type application/octet not allowed for parameter DataHandler_4 allowed types are [text/xml]
      [java] at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:522)
      [java] at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:273)
      [java] at org.jboss.ws.core.jaxrpc.client.PortProxy.invoke(PortProxy.java:151)
      [java] at $Proxy0.sendPart(Unknown Source)


      I would like to be able to send */* types. How is this done? Any samples would be appreciated. Also, where can I get the schema for the configuration file and a better explanation on how to use wstools?

        • 1. Re: How do I use MIME types other than text/xml
          Heiko Braun Master

          Looking at that exception


          java] org.jboss.ws.core.jaxrpc.binding.BindingException: Mime type application/octet not allowed for parameter DataHandler_4 allowed types are [text/xml]


          i assume that you are not using MTOM at all. That particular error occurs when sending an SWA attachment where the mime types of the datahandler doesn't match the WSDL.

          I would suggest to first make sure that mtom is enabled for your endpoint:
          http://jbws.dyndns.org/mediawiki/index.php/JAX-WS_User_Guide#MTOM.2FXOP

          This would then already solve the later problem i guess.

          • 2. Re: How do I use MIME types other than text/xml
            Lee Brackman Newbie

            Thanks for you response. I attempted to get MTOM enabled on the server side as instructed in the link provided. Using wsprovide with the following endpoint configuration:

            @Remote
            @WebService(targetNamespace = "http://fileXfer.ws.synoran.com/")
            @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE)
            @BindingType(value="http://schema.xmlsoap.org/wsdl/soap/http?mtom=true")
            public interface FileXferEndpoint {

            public String sendPart(Long txId, Integer partNum, Long size, DataHandler data);
            }

            I am getting the following exception:

            org.jboss.ws.WSException: Unsupported binding: http://schema.xmlsoap.org/wsdl/soap/http?mtom=true
            at org.jboss.ws.metadata.umdm.EndpointMetaData.setBindingId(EndpointMetaData.java:178)

            Is the documentation update to date with regards to the URL needed for the binding type to enable MTOM?

            • 3. Re: How do I use MIME types other than text/xml
              Lee Brackman Newbie

              ok. I got past that issue. now I am getting an exception of the following on the client side:

              [java] org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://fileXfer.ws.synoran.com}SendPartRequest

              This is the SEI:

              @WebService(targetNamespace = "http://fileXfer.ws.synoran.com/")
              @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE)
              @BindingType(value = "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true")
              public interface FileXferEndpoint
              {
              public SendPartResponse sendPart(SendPartRequest request);
              }


              I have the XmlType annotation on the SendPartRequest message class with the @XmlMimeType("application/octet-stream") declared for the DataHandler get bean. I used the wsprovide tool to generate the wsdl and deployed the app server.

              @XmlType(name="SendPartRequest", namespace = "http://fileXfer.ws.synoran.com")
              public class SendPartRequest {


              public SendPartRequest() {
              }


              public SendPartRequest(long txId, int partNum, long size, DataHandler dataHandler) {
              this.txId = txId;
              this.dataHandler = dataHandler;
              }

              ...

              @XmlMimeType("application/octet-stream")
              public DataHandler getDataHandler() {
              return dataHandler;
              }

              public void setDataHandler(DataHandler dataHandler) {
              this.dataHandler = dataHandler;
              }

              Using the wsconsume tool I generated the source code for the client. The generated source code does not appear to use the wrapper classes however and requires me to supply the all the parameters that are wrapped in the SendPartRequest class to the web service method call. I can't seem to find any reference to the SendPartRequest class in any of the generated code.

              Is there something that I am missing here?

              • 4. Re: How do I use MIME types other than text/xml
                Lee Brackman Newbie

                Found the problem. Apparently I had some imports that were in conflict with each other. I had ws classes mixed in with rpc classes such as

                javax.xml.rpc.Service -and- javax.xml.ws.Service.

                Obviously you can't use javax.xml.ws.Service in an rpc web service and you can't use javax.xml.rpc.Service in ws web services :-S