with the CN1 web service wizard, I created a working server project that I run on my local Tomcat installation. in addition, the CN1 project has the webserviceproxy.java class that I use to call the web services. so far so good.
During development, there now is the need to create a new function within the webservice that I did not previously think of. So instead of recreating my whole server using the wizard, I thought I simply add some code into the files that were created.
On the client side:
WebServiceProxy.java - add WebServiceProxyCall.WSDefinition and add the function call in sync and async fashion. the arguments and return type matches the definition.
On the server side:
WebServiceProxyServer.java
- add the function definition with the required functionality (this works as I have it debugged it locally on the server side).
CN1WebServiceServlet.java - add definition and add the if statement matching the service name.
when debugging the server and calling the service from the client, it does not reach the breakpoint of the doPost method, so something is terribly off.
What else do I need to change when manually adding a new webservice function? Or is this so complicated that I should better use the web service wizard, create the new server from scratch and copy all the other functionality from my old server to the new one?
Thanks and best regards
There is currently no way to do this seamlessly since the generated protocol is binary for fastest protocol performance.
The solution is to generate a new class we usually use the notion V2, V3 onward. That way the first webservice is still 100% compatible to devices in production and you can create a new "more correct" protocol for the newer devices. The implementation classes can derive from one another to increase code reuse.
Related
I am trying to use an UWP app service to provide some non-UI processing service to other app including the host app. For responsiveness, I want to return the result progressively. Think about grep-ping a folder for files containing a certain string: It would be better to report the files as we found it instead of reporting everything at the end.
So my question is: Can this scenario be achieved with the current UWP technology? (I think it is probably possible via polling using the multiple app instances approach. I want to know if there's an easier method with app service.)
The AppServiceConnection is a bi-directional communication pipe, so you can use it to communicate progress updates from the service to the client. No need for polling. Just retain a reference to the AppServiceConnection instance in your service implementation once the client has connected and then call SendMessageAsync to send progress updates to client whenever you want.
My application it's C++ service. And I need to add API for it. I consider that it will be XML/JSON RPC based API. How should I design a program for reusing existing code base and provide API.
I see following options:
My application will work via RPC layer. Seems that it's bad option due to low performance;
Before starting of service I will fork it and run my application in the first process and RPC server in the second; Seems ok, but how to restart RPC server in this case?
I guess there is a well known pattern for such issues.
Thanks.
If you can use a web server, then the FastCGI concept might be what you're looking for. One of the main duties of FastCGI is to allow you to put on a public API (from the web server) that internally calls the "real" application, in your case the resident C++ service. So all work is done at the web server to create the public API using any technology you wish, and little or no code changes done in your C++ service.
I am writing a biztalk orchestration that will need to call a web service, probably multiple web services, and probably more than once. I see two options before me; one, consume the wsdl in a separate code project, and call the web services from code in an expression shape, and two, consume it from Biz, get schemas, etc and call through request/response ports. What is the best practice here? On the one hand, if the wsdl is updated it will be easier to update the code than the schemas and ports, and it seems like a lot of clutter and work to build ports enough for multiple web service calls. On the other hand, all the tuning you can do at the port level(retries being one) makes it robust to call web service.
Also see this question here, which discusses a 3rd option, viz using add service reference in BizTalk as an alternative method to import XSD's.
IMO you would be defeating the point of using BizTalk by using .NET proxies to handle integration. For example:
You are hard coding the protocol (WCF), and now need to marshal request and response messages to / from your custom code. With a send port, any request-response mechanism can be configured at deployment time - especially useful for unit and integrating testing.
You will be losing all of the benefit of BizTalk's message delivery mechanisms, such as retries, backup transports, resume suspended messages, different maps for different ports, and arguably the whole pub sub ability, (e.g. what if multiple listeners want to listen to the responses from the called web services?)
Where will you store the WCF serviceModel config settings, such as the endpoint etc? i.e. You've lost the flexibility of binding files.
etc.
So, TL;DR Always use the WCF adapters in BizTalk
However, that said, am in agreement that updating generated items if the consumed service changes can be messy. FWIW, we mitigate some of this as follows:
Always create a separate, empty folder in which to import all the
imported generated artifacts.
Leave all the generated items 'as-is', i.e. don't be tempted to move the dummy .odx, or delete it (since it has the preconfigured Port Types)
Unfortunately this leaves the below actions which still need to be manually applied:
Remember to change the visibility of the Port Types to public if the artifacts are in a separate assembly to your orchestrations
Promoted and distinguished properties on the imported schemas need to be reapplied (e.g. remember to document screen shots after any change). Possibly this can be simplified or automated by saving and re-pasting in the <xs:annotation> section of the schma.
If you are using message contracts in your WCF service, and are reusing the same referenced messages across multiple applications, you will need to manually delete the duplicates created by the add generated items and then re-reference the existing schemas. (e.g. we have a standard 'response' message back to all BizTalk calls)
Interestingly, you can have a mixture of both infact. Check this out by Saravana Kumar!!!
It uses passthrough receive and consumes a webservice using the dll on the send port, without going through the pain of creating schemas and webports.
This gives all the power of Biztalk ( routing response, send port configuration, etc) and still the flexibility to change the schema without much fuss.
I am looking for a clean way to add service oriented access to an existing GWT application (client + RemoteService based server). The thing is that all the services are already in place, described by the #RemoteServiceRelativePath notation. It would be nice to be able to actually add the #WebService notation and have access to them both with RPC and XML/JSON/..
The real problem is that extending a current application to support other clients than the existing GWT one is a bit hard because of the GWT obfuscation. This also leads to an unneeded coupling between client and server since they both need to be deployed at the same time, because of the .gwt.rpc generated files.
I would like to reuse the existing RemoteService interfaces to define web services and connect to them with new clients via a plain-text protocol. Additionally, I would like to port the existing GWT client to the same protocol.
Is it possible to do this while using the same interfaces and implementation just by annotation?
What would be the best way to port the existing client to use a plain text protocol, RequestBuilder? Or just inject a new serialization implementation that does xml / json?
I don't even know where to start with this, this is why I'm asking. Maybe it is better to rewrite all the services and port everything at once but it will break everything until this is finished.
We've had a different approach since GWT the coupling of GWT between server and client side is not all bad but gives you a nice integration and you don't have to think too much about communication issues etc.
For that, our application had a frontend tier which consisted of the full gwt stack (client + server-coupling) and on the server-side, we connected via spring and RPC to the service layer.
On that way you can use on the benefits of spring and you don't loose the comfort of GWT.
But I Would like to hear if somebody already has gone other ways ;)
This is rather late and GWT is not the wonderchild it once was. However, for the sake of tying loose ends here's the solution I went for:
create a Java generator that parses all model (shared client/server classes) files through reflection and generates a Java file that reads/writes SOAP objects
bootstrap the above into a generic Java handler that handles native objects + array, sets, maps
write the service that can deal with the generated XML from the files above
It sounds a bit terse and a bit complicated but it 'only' took ~1 month to write the code to reliably convert >200 objects to their XML representation, automatically. The added benefit is that it allows mocking and cross-platform clients/servers.
As a summary, the generated code creates new methods 'fromXML' and 'toXML' that feed the fields that are public members (get/set) in the given class. So, given MyClass it would generate the MyClassSerializer and MyClassDeserializer Java classes that implement those SOAP-specific methods and also publish themselves to a 'dispatcher'. So whenever that dispatcher sees 'MyClass' it would know where to get the ser/deser functions from.
How can I configure jetty6 to start a non web application (not a servlet)? My Java app is a rabbitmq consumer listening for ampq messages over tcp. I could have jetty init() call my Main entry point. Is there a better way to do this?
Why not provide a trivial servlet that provides an init() method and invoke your application from within there ? i.e. wrap it within a servlet wrapper that does next to nothing.
It doesn't have to respond to GETs/POSTs etc. Although you'd probably find that useful and report application status via a simple HTML page.
You'll need to provide a little more info if you want a complete answer but there are a few approaches I could suggest, that will give different behaviours (you'll need to pick the right one for your use case)
1. Just put the right code in your jetty.xml file. The XML file is a pretty complete execution language, so you can simply call methods on objects. An appropriate static method, along with a <call> tag should do the trick
The downside, is that you're not really getting any thing from Jetty - you just tying your startup method into the same startup process that Jetty uses.
2. Build a component that implements the Jetty LifeCycle interface (your best option is to extend AbstractLifeCycle), and then call Server.addLifeCycle()
That will allow you to open your port when Jetty starts up, shutdown cleanly when Jetty, stops, etc.
But all you get is that lifecycle. You don't get anything around deployment.
3. Same as option 1, but put it in jetty-web.xml (or jetty-env.xml), which allows you to tie it into the deployment of a WAR file.
It doesn't buy you much over option 1, but if you're trying to deploy an application to an existing Jetty setup, it might help.
4. Same as option 1, but using jetty-web.xml. I'm not sure how well that would work, since I don't think you can attach a LifeCycle to a WebAppContext, but it might work OK - you'd need to do more investigation on that.
5. As per Brian's solution, simply write a servlet with an init() method, and initialise-on-startup, then don't map it to any URLs. Put a call to your entry method inside that init.