Creating client using Ws import not generating service and port class - webservice-client

I generated wsdl using Ws gen in my application. For that wsdl I tried to generate client so used Ws import with Maven. Client generation is successful but only request, response, exception, object factory and package classes are created.
There is no class for the service reference. What is the issue?
If service class not needed how to call the service from my client file
Thanks

I have once seen this problem with Java SE 'wsimport' command.
In my case service publisher's 'wsdl' SOAP port uses non-standard SOAP 1.2 binding.
Also, it's Service does not contain any usable ports.
It might show you some warning messages like this:
[WARNING] Ignoring SOAP port "XXXSoap12HttpPort":
it uses non-standard SOAP 1.2 binding.
You must specify the "-extension" option to use this binding.
...
[WARNING] Service "XXXService" does not contain any usable ports.
try running wsimport with -extension switch.
...
Adding -extension switch to the 'wsimport' command did the magic in this
case.
wsimport -keep -p com.samlpe.jaxws.client -extension <WSDL URL>

Related

Camel to route external REST web service

I'm working on spring MVC and using Apache camel to integrate external services.
I wanted to use Apache Camel route to make a Webservice call.
Like my local REST service (http://localhostsmiliex.xx:8080/users) fetching data from external REST service (http://xxx:000/users) and wanted routing to fetch external data.
Which Apache component would be suitable for a web-service route such as Jetty or producer template?
Have you tried HTTP4 or HTTP ?
http://camel.apache.org/http4.html
Use ProducerTemplate, it works like a charm for calling external endpoints REST, DB, SOAP etc..
You can either autowire it
#Autowired
ProducerTempalete prodcuerTemplate
prodcuerTemplate.sendBody("http://xyz...", "<hello>world!</hello>");
or
ProducerTemplate template = exchange.getContext().createProducerTemplate();
// send to default endpoint
template.sendBody("<hello>world!</hello>");
// send to a specific queue
template.sendBody("http://xyz...", "<hello>world!</hello>");

Requirements for the Spring Integration Http Outbound Adapter with ASP.Net

I have a CRM application that is using spring integration framework to send out updates to other systems. Currently the integration is running thru JMS, in which an xml message is sent to a JBossMQ queue. This needs to change so that a .Net application can handle the events.
In looking thru the vendor documentation, I found one option is to use an HTTP Adapter, excerpt here
HTTP Adapter Configuration
Ensure that the spring-integration-http-2.2.0.RELEASE.jar file is located in the folder /webapps/WEB-INF/lib.
Add the namespace and schema for the file adapter in the simple-file.xml with the relevant details:
<xmlns:si-http="http://www.springframework.org/schema/integration/http"
http://www.springframework.org/schema/integration/http
http://www.springframework.org/schema/integration/http/spring-integration-http-2.2.xsd>
Add the http outbound channel adapter configuration as follows:
<si-http:outbound-channel-adapter channel="<application_event>" order="2" url="${ http.url }" http-method="POST">
<si-http:request-handler-advice-chain>
</si-http:request-handler-advice-chain>
</si-http:outbound-channel-adapter>
• Channel: Set this value to the location that messages are published.
• Order: This refers to the priority when multiple adapters are configured.
• URL: The setting http.url (http://bfs-product-30:9090/ecmsi/case-events) Within the integration.properties file refers to the location where messages will be pushed and which http inbound adapter is configured to receive the
messages.
• Http-method: This refers to methods through which data is sent to consumer. E.g. Get/post etc..
• Retry: This is done by using
the defCircuitBreakerAdvice bean.
After googling this morning I am sure what the requirements are for the http adapter, all examples appear to be within a spring web application.
Can I create a asp.net .ashx application that reads the xml from the request object.

Is there a component in camel for a service built on Spring RestTemplate?

I have a REST Service running in Tomcat server. I created this REST Service using Spring RESTTemplate. So is there a component in CAMEL to use this exposed Web service?
i have used http component. i am aware that we cannot use http component to expose a service. So please let me know which component to use.Here is a detailed description of the problem.
Service created in rest Template runs in a server which you can see in from part of camel code
i use camel to expose this service to another http service and the response of this service is the response from the other service.
so my camel code looks like this:
from("http://localhost:8080/rest/emp/dummy").to(http://anotherweservice.com")
I get this error.
Failed to create route route1: Route(route1)[[From[]] -> [process[com.routes..... because of uri must be specified and not empty
Have a look at http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html.
Using the Jetty component, this looks as follows:
from("jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true")
.log("myapp: httpPath = ${header.CamelHttpPath}")
.to("jetty:http://localhost:8082/remoteapp?bridgeEndpoint=true&throwExceptionOnFailure=false")
In this example, the request is forwarded to another Jetty Camel endpoint:
from("jetty:http://0.0.0.0:8082/remoteapp?matchOnUriPrefix=true")
.log("remoteapp: httpPath = ${header.CamelHttpPath}")
.setBody(simple("${header.CamelHttpPath}"));
The HTTP path /hello/world is transfered to the endpoint, as can be seen when the service is invoked with http://localhost:8080/myapp/hello/world. In this case the body /hello/world is returned. And in the log it says:
INFO myapp: httpPath = /hello/world
INFO remoteapp: httpPath = /hello/world

Could not find default endpoint element that references contract 'Service' error in consuming web Services in asp.net mvc

I have a problem when calling web Services in ASP.net MVC , I do the following
add the web service by add service reference to solution, and I include the service.cs file to the solution also, but when I try to create object in home controller , I have the following error
Could not find default endpoint element that references contract 'Service' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
can any one help me please
thanks
There's a couple things going on here. First, you're using SVCUTIL to generate a proxy and configuration settings for a non-WCF service - .asmx is legacy. I was able to generate a proxy and config settings, but to overcome the error you got you need to call one of the overloaded versions of WeatherHttpClient.
I'm not 100% sure, but this is what I think based on what I observed.
The reason is because there are two endpoints defined in the configuration file (one for SOAP 1.1 and one for SOAP 1.2), and since both endpoints are named there is no default endpoint to choose from.
When I used var x = new WeatherHttpClient(new BasicHttpBinding("WeatherSoap"), new EndpointAddress("http://wsf.cdyne.com/WeatherWS/Weather.asmx")); I was able to create the proxy just fine.
However, when I called GetCityForecastByZip I got the following error:
Server did not recognize the value of HTTP Header SOAPAction: http://ws.cdyne.com/WeatherWS/WeatherHttpGet/GetCityForecastByZIPRequest.
So then I used WSDL.exe to generate the proxy a la .ASMX style. I included that in my project, and the following code returned a result (after including a reference to System.Web.Services - I was using a console app):
var x = new Weather();
ForecastReturn result = x.GetCityForecastByZip("91504");`
I would suggest for simplicity using WSDL.exe to generate the proxy for your service, as it seems to be simpler.
I will also add that I've done very little MVC, but I don't think this is an MVC issue. I hope this helps you.

Consuming a Web Service from a Class Library

Using Visual Studio I have a Class Library (C#) where I added a reference to a Service (more preciselly a Web Service).
The Web Service classes and interfaces where generated correctly, and I am trying to consume them using the following code (the web service receives an returns a string):
CallWS request = new CallWS();
request.input = "input string";
WSClient client = new WSClient();
CallWSResponse response = client.CallWS(request);
The last line originates the following exception:
Could not find default endpoint element that references contract 'WS_INTER' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
How do I solve this?
You have to add an application configuration file and set up system.serviceModel section defining the address of a service.
You can certainly do that in code. Check this or MSDN for description

Resources