views:

555

answers:

1

Hi all, I'm having a problem with a WCF Service and Java Client, I will try to give as much information as i can, thanks for your time.

The Endpoint of the server is BasicHttpBinding, I tried hosting the server as a Windows Service and in IIS but nothing changed. The weird thing is that the Client works great if I use a simple class, in the moment I switch the class to an JApplet I get the problem mentioned.

I'm using Eclipse as an IDE, I tried Axis and Metro to generate the stub with the same bad results.

Here is an example of the Java class where everything is working

public class TestSoaMetro {
    public String TestMethod(){
     String result=null;

      IDigitalSignatureService aa = new DigitalSignatureService().getBasicHttpBindingEndpoint();
      try {
       result= aa.getData("1", "id002962");
      } catch (IDigitalSignatureServiceGetDataArgumentExceptionFaultFaultMessage e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      } catch (IDigitalSignatureServiceGetDataInvalidOperationExceptionFaultFaultMessage e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
     return result;
    }
}

Here is the example of the JApplet where I get the error:

public class TestSoaMetroApplet extends JApplet {
     public void init() {
         Container content = getContentPane();
         content.setBackground(Color.white);
         content.setLayout(new FlowLayout()); 
         String result= this.TestMethod();
         JLabel label = new JLabel(result);
         content.add(label);
       }
    public String TestMethod(){
     String result=null;
     IDigitalSignatureService aa = null;
     try {
      aa = new DigitalSignatureService().getBasicHttpBindingEndpoint();
      result= aa.getData("1", "id002962");
     } catch (IDigitalSignatureServiceGetDataArgumentExceptionFaultFaultMessage e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     } catch (IDigitalSignatureServiceGetDataInvalidOperationExceptionFaultFaultMessage e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
    return result;
    }
}

In the moment the Applet loads I get the error, is the exact same call so I don't understand why I get the exception using the Applet. I Also tried to call this from a Silverlight client and I was getting a security exception, this is where I found out about clientaccesspolicy.xml and crossdomain.xml, I added clientaccesspolicy.xml to the service and the Silverlight Client works great, so I decided to try crossdomain.xml and nothing, the Applet still does not work. I will put the stack trace at the end, thanks all for your time.

Juan Zamudio

javax.xml.ws.WebServiceException: org.apache.axis2.AxisFault: Transport error: 405 Error: Method not allowed
at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:559)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:118)
at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:82)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:317)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:159)
at $Proxy12.getData(Unknown Source)
at TestSoaMetroApplet.TestMethod(TestSoaMetroApplet.java:28)
at TestSoaMetroApplet.init(TestSoaMetroApplet.java:19)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.axis2.AxisFault: Transport error: 405 Error: Method not allowed
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:295)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:190)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:389)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:222)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:554)
... 9 more
A: 

The exception is obviously caused by an HTTP 405 error, so it is the server, which decides that the client is not allowed to invoke the method. If it is an applet or a standalone Java application should not really matter. Is the applet and the standalone application perhaps accessing the server from different IPs and the server is configured to allow access from the IP used by the standalone app, but denying access from the IP used by the applet?

jarnbjo
right now all clients (standalone and applet) have the same IP, that means my debug machine, that is why is so strange to me.
Juan Zamudio
Perhaps the applet is using the browser's proxy configuration so that the server is seeing a different client. Perhaps (most likely) you'll find a detailed explanation in the server logs why the request is denied. Perhaps are cosmic rays changing the bits in the server CPU register, so that the request fails. It's impossible for someone to _guess_ what your problem is, if you don't provide any detailed information.
jarnbjo
you didn't request more info, but thanks anyway, its stuff like this that's keep away of this kind of sites. (by the way an 405 error has nothing to do with security),
Juan Zamudio
If you had searched Google for something like "iis soap 405", you had found a lot of interesting situations, in which IIS returns a 405 error code. It should only be used if the HTTP method (GET, POST, etc.) is not supported, but according to your stack trace, you are sending a POST request (which has to be supported) and IIS is obviously using the 405 response code for several problems. Since you have two almost identical clients, one is working and one is not, the most obvious reason is some different in their runtime environments. Applet vs standalone app is very unlikely.
jarnbjo
If you read my question again I mentioned that the same happens on a self hosted version of the WCF service so is not an IIS issue, since I can’t install fiddler at work I will call it a day, well even if could see what the applet is doing I can’t do anything about it, the stub generator is supposed to read the WSDL and call the service as defined, which does work but not in the applet environment.I made this work using a Web Service instead (just moved my code, even the DataContract, interfaces and classes are identical.Thanks for your help.
Juan Zamudio