We help IT Professionals succeed at work.

Calling a .Net web service that uses MTOM from java application with SDK 1.5

Cyber-EE
Cyber-EE asked
on
Medium Priority
1,427 Views
Last Modified: 2012-05-06
Hi,

Im a rather new user in java. I have a project in .Net that has 1 web services that uses the MTOM protocol to download a file. I want to use this web service but from a java applet.
When i call the web service (After i added a new web client to the applet project) I get the error message "HTTP Status-Code 415: Unsupported Media Type".
If i do the same but call a web service that does not use MTOM then it works fine.
Can someone please help me? I've searched the web but did not find any usable information. This is might be becuase im a new user and don't know what to search for :)
Thank you.
Comment
Watch Question

Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Hi,

ThanX 4 the reply. I tried to do as the document explained but still get the same result...
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
CERTIFIED EXPERT
Top Expert 2016

Commented:
You need to use JAX-WS and enable MOTM. See

http://java.sun.com/webservices/docs/2.0/jaxws/mtom-swaref.html
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
enabling motm has already been suggested.

Author

Commented:
Hello to all,

A read the link that objects told me and i think that it is not my case because as i said i already checked MTOM using a client and web service in .NET and it worked fine.
Regrading the 2nd link i was given - As i understand, they talk about enabling a web service that was written in Java and how to enable it for MTOM. This is not my case. I might have not understand the solution but i tired all that was written there and no luck.... :(
CERTIFIED EXPERT
Top Expert 2016

Commented:
My link discusses the server *and client*:

>>MTOM feature is disabled in jaxws by default. It can be enabled on the client and server.

and there is an example later of enabling support in the client

Author

Commented:
Yes, you are correct but i already tried that way to enable MTOM but it seems to have no effect. I still get the error  "HTTP Status-Code 415: Unsupported Media Type".
I am sure im missing something but because i new to Java i don't know what..
CERTIFIED EXPERT
Top Expert 2016

Commented:
Are you using jaxws as client API?

Author

Commented:
Hi CEHJ,

As i said at the start :) iam am new to java... Can you explain what you mean. I did install the jaxws library in my project.
Maybe you want me to explain what are the steps i did to create a web service client? It might help you understand my problem?

Author

Commented:
Hi again,

I found an artical on the jaxws client API. i'll try to use it and let you know.
I actually created a web service client using the the Netbeans option to call web service resources.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

Author

Commented:
still not working.
Will it help you if i add the code that i use to create the client and the wsdl file?
If you need something else let me know.
ThanX
CERTIFIED EXPERT
Top Expert 2016

Commented:
Are we able to call this ourselves?

Author

Commented:
No...

Author

Commented:
Hi,

Now you can call it from
http://194.90.225.103/mtom/mtomwse.asmx?wsdl

Please let me know if you can help me.
ThanX
CERTIFIED EXPERT
Top Expert 2016

Commented:
Yes, i've done it successfully using my own advice. See my code below. I also attach an image of the output in Netbeans:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package webservice;
 
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.BindingProvider;
 
/**
 *
 * @author goose
 */
public class Main {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        MTOMWse mtom = new MTOMWse();
        
        MTOMWseSoap soap = mtom.getMTOMWseSoap12();
 
 
        SOAPBinding binding = (SOAPBinding)((BindingProvider)soap).getBinding();
        binding.setMTOMEnabled(true);
 
        System.out.println(soap.helloWorld());
    }
 
}

Open in new window

nb.png

Author

Commented:
Hi,

1st of all thanX for the reply.
I noticed that you used mtom.getMTOMWseSoap12();
In my test i used mtom.getMTOMWseSoap(); so tried your way and noticed that when i refresh the web client and build the project i get the message "warning: SOAP port "MTOMWseSoap12": uses a non-standard SOAP 1.2 binding.". This is after got the message "warning: Ignoring SOAP port "MTOMWseSoap12": it uses non-standard SOAP 1.2 binding.
You must specify the "-extension" option to use this binding." and add "extention="true"" to the "build-impl.xml".
I am still getting the "HTTP Status-Code 415: Unsupported Media Type". when running it.
Am i using a different java version then you? Might this be why i keep getting the HTTP error?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
not sure why he used that binding. did you try the lab I posted earlier?
( i don't use netbeans so can't try it here)

Author

Commented:
I'll try the lab you gave me again because the 1st time i tried i had some problems using it.
About the soap12 binding i installaed SDK 1.6 with netbeans 6 and still got the HTTP error.

Author

Commented:
I am having problems using the lab demo as is. If I need to do changes in the code i prefer not do it because I don't have that time to spend on it. If someone, anyone, has another idea Ill appreciate it.
???

ThanX
CERTIFIED EXPERT
Top Expert 2016
Commented:
>>Am i using a different java version then you?

Well i did it with Java 6 but did get the very latest JAX-WS first, so try doing the latter and adding that latest library to the project instead. Get rid of the existing JAX-WS libraries
CERTIFIED EXPERT
Top Expert 2016

Commented:
If you can't get it working, although of course it would be better for you to do so, i can always send it to you.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.