Java SOAP client very slow - wsdl

I am building a client for a web service. I didn't want to the client downloading the wsdl everytime and got this answer.
But evaluating the source files of WSServiceDelegate,
URL url = wsdl.getSystemId()==null ? null : JAXWSUtils.getEncodedURL(wsdl.getSystemId());
WSDLModel model = parseWSDL(url, wsdl, serviceClass);
service = model.getService(this.serviceName);
if (service == null)
throw new WebServiceException(
ClientMessages.INVALID_SERVICE_NAME(this.serviceName,
buildNameList(model.getServices().keySet())));
// fill in statically known ports
for (WSDLPort port : service.getPorts())
ports.put(port.getName(), new PortInfo(this, port));
I see that it still parses the wsdl to get the service. How can I get around that. I provided the endpoint url using the context.
I need the client to be as fast and as small as possible, adding a huge wsdl in there is worst than downloading the wsdl.

For the operations you are interested in, you can build your own SOAP messages based on the wsdl's Request/Response messages and the xsd. You can use Jaxb tools to convert from XSD to Java classes. You then need to make post calls using Http Clients (like Spring RestTemplate) to post the POST body, soap based, to the endpoint address. This will make your calls faster but you have to code more in order to benefit.

Related

how pass parameter usin soap web services in ios app

This is my first application to call soap services. generally i am use php service.please any one help to how to call soap service and how to pass parameter using soap service in ios
.
Giving pythonic way for tax-web page (should be similiar to php only libs will be different):
import suds
from suds.client import Client
client = Client("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
result = client.service.checkVat('GB', '11120021' )
In wsdl file you will always find which parameters you should feed to get back result

Serving a webpage with Redstone

I am developing a web application with Dart using redstone and polymer
Because Dart allows for server and client side development, I wonder what a good pattern for a web application is (specifically to Dart)
Option 1:
Have a server, say, /bin/server.dart
1.1. get a request there and respond with json
#app.Route("/user/:id", methods: const [app.GET])
getUser(int id) { ... }
have a client, i.e. web/user.html and web/user.dart
2.1 in user.dart make a request to server
2.2 receive json and form a proper user.html
Option 2:
Have a server /bin/server
1.1 get a request there and respond with an html page, similar to
#app.Route("/")
helloWorld() => "Hello, World!";
If in the first case I more or less know (and understand) how to make things work, while i find it really frustrating that I do not take advantage of Dart's server-client code-sharing: I need to encode to and decode back json to get the same data. Is there a way to avoid it?
The second option is much less clear for me: how would I serve a web page in this way? How would I make Polymer do its work?
Answers on the questions in the text and a general explanation of a darty way to develop web apps are very much appreciated.
You can see a Redstone + Polymer application example here: https://github.com/luizmineo/io_2014_contacts_demo
Basically, it works as Option 1: The client and server communicates through a service API, and the data is encoded as JSON. Although, Redstone uses the shelf_static package to serve the client code to the browser as well.
If you prefer, it's also possible to use a server side template engine, such as mustache, to build html pages in the server, although, I think it would be really difficult to integrate that with Polymer.
And finally, you always have to encode the data someway when transferring data between client and server, but this doesn't means they can't share code. They can use the same domain classes, for example. Check out the sample application linked above for more details.
I don't think the option 2 is possible. Polymer depends on dart:html which is not allowed on server side.

Is there a way to browse WSDL endpoints using a browser?

I want to test the results from a WSDL service in a browser like IE9 or FireFox. I know that I can view the WSDL XML, but I want to test the return results of an endpoint called GetEmployeeById that accepts a parameter called Id and returns a class. I am assuming this is all serialized to XML, so a browser would be a good fit for testing this. Is this possible?
In case you are using Visual Studio for .net development, I think something much better than a browser probably would to use:
wcftestclient <url>
which can be called from the command prompt and is part of the tools from visual studio.
The tool will help you to build and receive complex objects and see the results already serialized.
internet explorer let's you make a request with simple string parameters if the WSDL provides enough information.
If you haven't seen it, then probably the WSDL is only for discoverability reasons, probably just points to another service in a different transport protocol, not port 80, if the service is not on port 80 you won't be able to use your browser.
You have another more complex tool called FIDDLER that you can format any kind of http request, as well as receiving any kind of requests, like json for example.
You can use this URL to test WSDL endpoints, send request and see response.

CXF client loads wsdl for both service and port?

In a java web app, I need to call a remote soap service, and I'm trying to use a CXF 2.5.0-generated client. The soap service is provided by a particular ERP vendor, and its wsdl is monstrous, thousands of types, dozens of xsd imports, etc. wsdl2java generates the client ok, thanks to the -autoNameResolution flag. But at runtime it retrieves the remote wsdl twice, once when I create the service object, and again when I create a port object.
MyService_Service myService = new MyService_Service(giantWsdlUrl); // fetches giantWsdl
MyService myPort = myService.getMyServicePort(); // fetches giantWsdl again
Why is that? I can understand retrieving it when creating myService, you want to see that it matches the client I'm currently using, or let a runtime wsdl location dictate the endpoint address, etc. But I don't understand why asking for the port would reload everything it just went out on the wire for. Am I missing something?
Since this is in a web application, and I can't be sure that myPort is threadsafe, then I'd have to create a port for each thread, except that's way too slow, 6 to 8 seconds thanks to the monstrous wsdl. Or add my own pooling, create a bunch in advance, and do check-outs and check-ins. Yuck.
For the record, the JaxWsProxyFactoryBean creation route does not ever fetch the wsdl, and that's good for my situation. It still takes a long time on the first create(), then about a quarter second on subsequent create()s, and even that's less than desirable. And I dunno... it sorta feels like I'm under the hood hotwiring the thing rather than turning the key. :)
Well, you have actually answered the question yourself. Each time you invoke service.getPort() the WSDL is loaded from remote site and parsed. JaxWsProxyFactoryBean goes absolutely the same way, but once the proxy is obtained it is re-used for further invocations. That is why the 1st run is slow (because of "warming up"), but subsequent are fast.
And yes, JaxWsProxyFactoryBean is not thread-safe. Pooling client proxies is an option, but unfortunately will eat a lot of memory, as JAX-WS runtime model is not shared among client proxies; synchronization is perhaps better way to follow.

How can I create and process SOAP requests in Delphi without HTTP?

Is there a recommended way / a tutorial which shows how to create and process plain SOAP request with Delphi without THTTPRio, for example, if I want to implement SOAP over JMS, SOAP over AMQP or SOAP over SMTP?
Simplified code examples:
// create a SOAP request (client side)
RequestXML := Service.Add(Arg1, Arg2);
This code would generate the XML with the SOAP message for the 'Add' method invocation with the arguments Arg1 and Arg2.
// process a SOAP request (server side)
ResponseXML := Service.ProcessRequest(RequestXML);
This code would take the SOAP request XML and invoke the method. The result of the method invocation will be wrapped as a SOAP response and is ready to be sent to the client.
Take a peek at the TLinkedRIO class ( http://shenoyatwork.blogspot.com/2004/10/using-tlinkedrio.html ). It creates the SOAP request and writes it to a file. Since TLinkedRIO is used for testing purposes, it also contains code to find a (Delphi) Server that implements the Service and have the server read the request from the file, process it and write a response to another file. The caller (client) then reads from the response file. If you want to use a different transport you won't have to do that part: the response will come from a true Service. However, it's a good example to show how the XML serialization is separate from the transport.
PS: The SOAP serialization basically expects IWebNode for its transport needs. And namely the Execute method of that interface. How/where you send the request stream to and how/where you get the response stream from is up to the transport implementation.

Resources