How can we use WCF services from iPhone? - wcf

I am implementing an application that displays data which is coming from a back end server. The back end server is using WCF for writing web services. I am not familiar with that WCF.
What can I try to resolve this?

If your WCF application is configured to be a SOAP service, then any SOAP libraries for iOS can be used.

You can make HTTP or SOAP requests to WCF. Given an HTTP request, for example, you could test it using cUrl. In it's simplest form, a cUrl get request is as follows:
curl http://stackoverflow.com
You very well may need to make POST or PUT request. If so you can review the docs here: http://curl.haxx.se/docs/httpscripting.html. I've included an example POST request using cUrl:
curl -X POST -H 'Content-type: text/xml' -d <YOUR PAYLOAD HERE> http://stackoverflow/fakepost
There a loads of ways to make HTTP requests, cUrl is just a client for doing so.
The following describes an iOS implementation of a POST request: iOS: how to perform a HTTP POST request? .

Related

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.

How do I clone custom HTTP Request Header Variables to the Response in IIS6?

I am currently working on a website where an authentication service (SiteMinder in this case) is forwarding a user's HTTP request on successful authentication to IIS6 while adding several custom HTTP header variables. Is there a way in IIS6 to clone (echo) these HTTP header variables and return them to the client as HTTP response header variables?
I am ultimately needing the equivalent of the Apache module mod_headers' "echo" command, detailed here https://httpd.apache.org/docs/2.2/mod/mod_headers.html.
MSDN has a good write up on working with HTTP header variables in IIS6.
HOWTO: Retrieve Request Headers using ISAPI, ASP, and ASP.Net

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.

Recommended testing frameworks for testing SOAP as well as REST services?

We have several WCF services - some with SOAP endpoints and others that with REST endpoints. There are also some services that have both SOAP and REST endpoint (diff. customer specs/demands). So far when it comes to testing, we've written custom test clients from ground up purely for testing the actual service+endpoints. However, I'm not sure if that's the best approach because we also have to maintain the test applications as a separate 'product'.
Is there any recommended approach to formally test these endpoints and services? Hopefully one framework/pattern that can cover both SOAP as well as REST sides.
SoapUI can test both SOAP and REST web services. Check out its other features.
This answer is specific to testing RESTful web services. We use the following tools:
RestClient is a Java application to test RESTful webservices.
curl - Comes in the Cygwin distribution for windows. You can find linux installables for your flavor of linux here. Sample uses of curl to make REST calls:
curl -v http://flickr.com/rogermenezes/photos/61 -H 'Content-Type:application/json' -H 'X-FlickrAPI-Version:1.0' -X DELETE
curl -v http://flickr.com/rogermenezes/albums -H 'Content-Type:application/json' -H 'X- FlickrAPI -Version:1.0' -X POST -d '{"name": "hawaii 2011", "tags": "vacation, hawaii, ", "creation_date": "2012-02-22T13:42Z"}'
Chrome Plugin - Advance REST Client
You can install this plugin through the Chrome Web Store. You can save past requests and the plugin also maintains a history of previous calls you had made.
Fiddler2
Fiddler2 snoops your network traffic. It also provides a way to "reissue and edit" past requests. Here, you can edit your past REST requests and execute them repeatedly.
You can use the headers section to provide security token. Our services are secured and I use SOAPUI to organize tests

Adding Authorization Header Explicity into WCF client

This question related to this post
Authorization Header is missing in Http request using WCF.
Is there way to explicity add authorization header into Http Request when making WCF call?
I am putting the same answer for this questions too that I put in the another question Authorization Header is missing in Http request using WCF. Because they are related. Actually, I was wrong about this question. I did see different behaviour when running HTTP analyzer. While Http anaylzer running, my application crashed after receiving 401 response. When Http analyzer application closed, the above code worked as expected. Since code worked as expected, authorization header was added by WCF.