Mule web-service proxy - mule

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.

Related

How to perform Load Test of WCF service having WebHttpBinding with JMeter

I am very new for JMeter. I want to test my WCF service which is using WebHttpBinding. I have gone through the documentation but no help in my case. Can you please suggest how to do that?
Most likely you need to add at least HTTP Header Manager and configure it to send Content-Type header with the value of application/json.
You can use View Results Tree listener to inspect request and response details - this way you'll be able to get more troubleshooting information.
Be aware of JSON Path Extractor and JSON Path Assertion which are extremely handy when it comes to working with JSON data.
See Testing SOAP/REST Web Services Using JMeter article for more details on web services load testing with JMeter.

WCF routing and service metadata

I'm building a WCF router which needs to act as a proxy for a number of internal web services (WCF and ASMX). The routing part is fairly straight-forward, but I can't understand how the service metadata exchange would work in this solution.
In other words: how would a client obtain metadata for an internal service behind the router? Do I need to manually supply WSDL files to the consumer? Can I somehow setup the router to return the metadata for an appropriate internal service?
Or perhaps my architecture is completely wrong?
I see 2 options here:
It may be an option to create a "non-transparent" proxy, if you don't want to expose the internal addresses. The advantage is that you can do more than just routing messages (i.e. such proxy may serve as a "security boundary", unwrapping ciphered messages and passing them plain to the internal endpoint). It can also provide an "interoperable level", exposing a WCF service as simple SOAP using same datatypes/message XML structure. The downside is that you'll have to update its code along with the proxied services
You may implement a WSDL rewriter. With it, you can mask the internal service URL on-the-fly - depending on your conditions, a simple string replace may or may not suffice.
Refer to:
Message Inspectors
IWsdlExportExtension
The same "router service" can also be used to get the individual WSDL for internal services behind the router.
Check out this thread
Have you considered using a simple HTTP Proxy instead? All WCF using REST or SOAP are at their core HTTP requests. It seems like the routing functionality (which I am assuming you are basing on hostname, URL path or parameters) could be performed by proxying the HTTP request without needing to understand the contents. ASP.Net will do a fairly good job of sanitizing incoming requests on its own, but you could always add additional custom filtering as necessary.

CXF Apache WSDL2Java set endpoint

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?

WCF basic auth to service that does not send 401 but 500 instead

I have to consume 3 web services (Sharepoint/Alfresco/Documentum CMIS) via WCF with HTTP Basic auth.
With Sharepoint or Alfresco, first request goes without Authorization header, receives HTTP 401, gets auto-retried by WCF with header, everything's fine.
But with Documentum, I receive HTTP 500 and a SOAP Fault instead, so WCF never gets an opportunity to send the header and returns the exception as-is.
I can of course add the headers manually via HttpRequestMessageProperty, but this looks like an ugly hack to me. Is there anything that could be configured on the WCF side to send headers with the first request, or on Documentum side to return 401?
You could try fronting the Documentum service with another web server that behaves properly, and passing the requests through?
I implemented something similar using IIS to front Apache Tomcat in order to use Windows Auth, and used the isapi_redirect.dll filter to pass requests through. More information about that can be found here: http://tomcat.apache.org/connectors-doc/reference/iis.html
Don't know if something like that is an option for you, but it may provide an easier solution in code.

Redirect the wcf service request to a internal address

Now i have a public Wcf REST service A, and several internal wcf REST services B, each of internal services are identified by name. Is it possible to create a router/proxy in service A, and then, when the users request the interface of service A, it can redirect the request to the internal services based on name?
I tried using:
WebOperationContext.Current.OutgoingResponse.Location = targetInternalPath;
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect; // or MovedPermanently
All works fine except the headers that we get on the client side, Here is the details from Fiddler:
Transport
Location: http://locahost:9856/internalAddress/getimage
Content-type: null (It should be "image/png")
Content-Length: 0
In other words, the client knows the exact internal address, the content-type and content-length is incorrect. All are not what i want. I have been struggling with this issue for days, anybody has any idea?
Best Regards.
Johnny
I'm confused. What you are seeing in fiddler is exactly what you are asking it to do. Your service A is returning a redirect response. The client is supposed to respond to that redirect by following the URI in the Location header.
If you truly want to hide the internal services then you need to make the service A work like a proxy. It needs to make the request to the internal services itself and then return the response it gets back.
Are you trying to hide the internal services for security reasons or is it just the clients don't know about those internal servers in advance?
The WCF RoutingService functionality can't be used because it only supports soap-based bindings. You could use the IIS 7 URL Rewrite Module as suggested here by Matthias in the MSDN forum answer. You could configure it to redirect the calls to the internal REST based services (an overview of its use at this link). I'm not sure it will help re-write the response header contents but it's worth a look.