Interoperate between C# and Java using web services without a Java EE application server?

前端 未结 4 2130
梦毁少年i
梦毁少年i 2021-01-06 19:26

I\'m in a difficult position: We have a 3rd party enterprise system that exposes a Java-based API. However, we are a 100% .Net oriented development team.

4条回答
  •  迷失自我
    2021-01-06 19:32

    I ended up finding a solution that was far easier than any of the above. We created some simple classes (like the doPing() method in @Thorbjørn Ravn Andersen's answer) with the @javax.jws.WebService and @javax.jws.WebMethod annotations, then deployed them using:

    string url = "http://localhost:8282/MyService"
    MyService serviceInstance = new MyService();
    Endpoint svc = Endpoint.publish(url, serviceInstance);
    

    I was then able to point Visual Studio at http://localhost:8282/MyService?wsdl and generate a client. Easy as pie.

    We have run a lot of requests through this service over a large span of time and have not noticed any problems. We wrapped this with the Java Service Wrapper so that it comes back up across reboots/JVM crashes, etc. A poor man's application server.

    I hope this might help any other .NET developer looking to interoperate with Java without having to remap your brain to do it.

提交回复
热议问题