CXF Apache WSDL2Java set endpoint - apache

In the beginning I have to warn that I'm not familar with web services, I want to simply generate what I need, and learn the basics of usage.
I recived .wsdl and .xsd files (stored localy). I have generated java code using Apache CXF WSDL2Java tool (I have generated a client). I also have an endpoint (as url without '?WSDL' on the end - whatever this endding means). How can I set this endpoint?
If I use:
Blachblach_Service ss = new Blachblach_Service(new URL(recived_url));
Blachblach port = ss.getBlachblachSOAP();
I get an exception. When I use soapUI to send XMLs to web services, everything works fine.

At first you need to initialize your web service client. See my answer over here how to make this work.
?WSDL ending means that you can see the web service WSDL file in your browser, you can access the web service through SOAP protocol by providing it with some valid request.
If you need to create your web service client using Spring. Here is very good example how to do this.

Yes usually we set params like end point URL on Service class object and retrieve port from it. and from port we invoke web service methods. can you please give details of exception you are getting?

Related

Nothing happens after adding service to Wcf Test Client

I added the service to the WCF Test Client app and I get Service Added Successfully, but I don't see any of the operations available.
This WCF service is already being consumed by several javascript charts, so I should be able to see something here.
What am I doing wrong?
By default, WCFTestclient doesn’t support call the Restful service by using a client proxy. WCF creates the Restful style service with WebHttpbinding. thereby the client proxy class generates nothing thought the service WSDL is available.
Besides, we are capable of making a successful call to the service by using a client proxy. please refer to the below link.
WCF: There was no endpoint listening at, that could accept the message
the above client proxy class is generated by adding service reference.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/accessing-services-using-a-wcf-client
Here is a detailed exposition of WCFTestClient from Microsoft document.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe?redirectedfrom=MSDN
Feel free to let me know if there is anything I can help with.
 

Does WCF Add Service Reference require something configured on the service to generate the app config?

We have an existing wcf service, and I created a new project. I want to use it. I hit add service reference, pop in the URL, press OK, and it adds it as a service reference but there is no config generated.
I also tried svcutil.exe /language:cs /out:GeneratedProxy.cs /config:app.config [url] but no config is generated, only the proxy cs.
I'm using VS 2013 / .NET 4.0
My question is, is this a sign that the SVC itself has some missing data that is required to build the contracts, or is the problem with adding the service reference?
For the record I have tried unchecking the reuse types option which some questions on here have reported as fixing the problem.
Bonus question, do you think if I can't get this working that manually adding some generic default bindings and endpoint code to the web config will work?
First, the reason that why the Adding service reference generates nothing is that the WCF service is rest style service. By default, the proxy-based invocation of rest style WCF services is complex.
https://en.wikipedia.org/wiki/Representational_state_transfer
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model
Calling the WCF rest style service with the client proxy is uncommon. Generally, we construct an Http request by using an HTTP client library to call the service, such as HttpClient, WebClient.
How to fix "ERR_ABORTED 400 (Bad Request)" error with Jquery call to C# WCF service?
Besides, calling the WCF rest style service with the client proxy is feasible. Please refer to my previous link.
WCF: There was no endpoint listening at, that could accept the message
Feel free to let me know if there is anything I can help with.

Mule web-service proxy

Given the free/open web-service for climate at:
http://eklima.no/wsKlima/standard/standard_en.html
with its web service interface at:
http://eklima.no/metdata/MetDataService
and WSDL at:
http://eklima.no/metdata/MetDataService?WSDL
I have been trying to use this as testcase for experimenting with mule web-proxy pattern configuration.
I have tried this config variant:
<pattern:web-service-proxy name="klimamet-ws-proxy"
inboundAddress="http://localhost:8080/klimamet"
outboundAddress="http://eklima.no/metdata/MetDataService" />
Now if i access the real web seb service directly, it will give me a proper response:
http://eklima.no/metdata/MetDataService?invoke=getMetData&timeserietypeID=0&format=&from=2006-01-01&to=2006-01-05&stations=18700&elements=tam&hours=&months=&username=
Then if i access the proxy just to get the wsdl, it works:
http://localhost:8080/klimamet?wsdl
but if I do a real service request towards the proxy:
http://localhost:8080/klimamet?invoke=getMetData&timeserietypeID=0&format=&from=2006-01-01&to=2006-01-05&stations=18700&elements=tam&hours=&months=&username=
then i just get the documentation page (same as: http://eklima.no/metdata/MetDataService), and not the expected soap xml-response.
I don't see any proper clue of what's wrong by looking in the logs.
By that way I have tried other variations of the config, but it just gives me other types of errors.
I will be thankful if anyone can help me spot the problem.
The Web Service proxy works with standard SOAP requests, i.e. HTTP POSTed SOAP envelopes. You are using HTTP GET here. Please use HTTP POST with the web-service-proxy.
If you really want to keep using GET, then switch to the pattern:http-proxy, which will forward the GET parameters to the outbound endpoint. Note that it will not rewrite the WSDL so clients of your proxy won't be able to rely on it.

Calling WCF service method from browser?

Since i am new to WCF and Having configured a WCF service endpoint in IIS at Virtual Directory Api ( url goes like
http://localhost/api/taskapi.svc)
i was looking for ways to make request through web browser something like
http://localhost/api/taskapi.svc/GetCompleted
would respond with returnd data .I know this requires the binding of web service with the webHttpBinding but i don't know how to do it any help would be great ?
Use WCFSVGHoST application to test WCF applications. Application enables you to key-in parameters value and execute method of your interest.
Link for the same:
http://msdn.microsoft.com/en-us/library/bb552363.aspx

WCF Service invoking - without any reference added

I want to invoke a wcf service for testing on the http layer. I do not want to add a service reference and create a proxy and invoke. I want to create a new web test(VSTS) which sends a http request to the service and posts(Http post) the request in http body as an xml.
I have service metadata, with which I can see the datacontracts, but the wsdl:operation has only the operation name, wsdl:input is just blank.
On the Contary, an asmx service will have the soap request in the metadata which can be copied as the http request body, with the parameters replaced.
How to build a wcf service xml body from scratch just by looking at the service metadata (no access to the service logs as well), have got just the end point.
It is something like
<root>
<element1>element1</element1>
<element2>element2</element2>
</root>
But, how to find out this, root has to be some thing like
<FunctionRequest xmlns=""http://schemas...."" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
(tested for a local service and worked)
Now, without having access to service logs(svctraceviewer logs), not able to add a service reference, not able to use svcutil.exe(certificate based service), just only with metadata - wsdl, is there a way to find out the request that is to be sent to service?
Well, you will have to create proxy - either statically by adding a service reference or running svcutil on your service metadata, or you can construct it dynamically totally in code, if you wish.
In that case, you'd have to have your service contract (ISomethingService) at hand, and check out the ChannelFactory < ISomethingService > () concept - that should get you started.
Marc
Yes you can, but you have to do a little work first.
Build the service client by running svcutil.exe on the wsdl/xsd metadata. This will generate a c# with your service and data contract objects. Compile that to an assembly using csc.exe.
See the soap envelope body you can create a request object and manually serialize it with data contract serializer. Or you can host the assembly in WcfSvcHost.exe and add wcf logging to the config file. In either case you will only have the correct xml for the body, and even that might be wrong if the real service uses xml serializer instead of data contract serializer.
The next part is the hard part because you need to know the security model for the real service. If it only uses certificates for SSL and server identification, you should be able to send the xml using WebClient. But if it uses mutual certs and/or security tokens, you pretty much have to create a channelfactory by hand with the right bindings.