This problem may be a little broad, but I'm going to go ahead and put it out there and then elaborate as needed on details.
My overall goal is a WCF rest service that when hit calls a WCF soap service, then parses the response of the soap service and extracts desired information and sends it back via http post (to a mobile device eventually).
I am having a problem getting the soap response to the rest service.
This is what is happening:
Console application calls rest service via http post. this is working
Rest service submits message to soap service. this is working
Soap service recognizes message and performs requested operation. this is working
After that, the return value is being generated in the soap service, but it isn't making it back to the rest service. I have tried numerous things. I've got the bindings identical, I've checked and double checked and triple checked the data contracts. I've tried quite a few things and what I'm wondering is if there is a problem using localhost to host 2 services. Both services are hosted locally and both are wcf services.
Would this cause a problem like the one I am seeing?
I will elaborate on the problem as needed as much as I can.
After fixing the problem, I can answer with confidence that running 2 services will not cause a problem. The actual problem in my case was caused by the bindings not being quite identical, once they were, it ran fine.
Related
I am developing a software that, apart from having its own BackEnd, has a module that must be integrated with an external web service. The external web service is as follows: https://e-seida.sunat.gob.pe/ol-ad-itseida-ws/ReceptorService.htm?wsdl
In the project (.NET C#), it can be easily referenced and I can see all the contract and methods that the external web service has exposed. I can do the same thing from the SOAP UI when I test successfully hitting the web service.
As you can see in the image, when you hit the web service, you have communication and a response from the SOAP UI. Now this does not happen in my project because although it is true the web service could be referenced, but until now I am still looking for the way or way to send the security data (UsernameToken) to the web service, honestly it is somewhat frustrating because I've been having this same problem for several days now and I can't give you a solution and researching I have found some possible solutions and none of them have really helped me.
I understand that the Header of this web service contains WS-Security type security, which is basically an open standard approved by OASIS to provide transport layer security (through SSL/TLS from HTTP).
I have also investigated some forums where they indicate that creating the following interfaces/classes (MessageHeader, IClientMessageInspector, IEndpointBehavior) but implementing that does not solve it either.
What can I try to resolve this?
Currently I have created a method in webapi to send a request by uploading the x509 certificate.
Now i need to write and application receive this request sent by the api and validate the certificate, could you please let me know how this must be done? I'm preety new to this.
You will likely want to use a web service as your receiver. It would impractical to explain how to create a web service as there are a tremendous amount of examples readily available by doing a quick search on google for C# Web Service or C# RESTful Web Service example.
Here are a couple of results to get you started:
HOW TO: Write a Simple Web Service by Using Visual C# .NET
Restful webservices in C#
If you work through one or two example projects and you run into a problem that you can't figure out, come back and post a new question. As it is, this question is a bit vague, so this will probably be about as specific of an answer as you're going to get.
Hi I have One wsdl file at my local machine. I tried testing it through SoapUI by sending an XML request with Header and SAML token asserted. When i added the WSDL file to my project's web reference, I can see the functions/operation which i want to consume and all its parameter which are to be passed but I cannot find a way to add header and SAML token to it.
Also the URL i have to hit is a HTTPS url so i have to add client Certificates.
All this i have tested over SoapUI and i am getting the response.. Al i want is how to send a request through dotnet code when my WSDL is at local. Since i am working for some Highly secured client i cannot reveal any code. I am posting this question on an assumption that this may be a common problem faced by people.
Please demonstrate your solution with an example.
You should consume your service with Wcf. That will allow you to abstract the transport details away from the client code. With this method you can have separate configurations between the server and client (production using HTTPS, plus no client configuration required, no HTTPS for local dev machine). There are tons and tons of great tutorials on WCF here and on the internet at large, so I'm not going to post a big long example here, but Google is your friend.
I'm looking at converting an existing web service into a Web API. I've only worked with a WS a little bit and it was a long time ago. What I do remember is that in my project I would make reference to a service location and then use that reference to call whatever method I needed.
EX: I would reference http://mydomain/webservicename/mobile.asmx and then would call objWS.MethodName() what was coded within the mobile.asmx file.
If I convert over to using a Web API I would basically call the HTTP by going to something like http://mydomain/controllername/myMethod.
As of right now I don't have access to the client code to be able to change the way that it calls the service. That being said am I stuck with using a traditional web service vs web api?
This is an app on a handheld scanner that I believe is running Windows CE. We are having some connectivity issues/database deadlocks and I was asked to look at it and see if I can help out. The current WS code is overly complicated IMO since it's only doing either an insert or an update to a database. I would also think that going with a Web API would make it a faster app since it's depending on cellular access for it's communication. JSON should be a smaller payload than XML.
So, I would like to just re-write it using Web API 2 and Entity Framework. However, I'm afraid I'm stuck to using WS since I don't have access to the client code.
Any suggestions?
It's a fairly broad architectural suggestion, but what you're proposing certainly sounds possible and even quite reasonable.
If I understand correctly, you currently have this:
Client -> ASMX Service
And you can't change the Client, only the ASMX Service. The first thing you're going to want to do this ensure that server-side business logic is de-coupled from the platform technology:
Client -> ASMX Service -> Business Logic
The idea here is that any application host should be able to reasonably invoke the same business logic, even if that logic is nothing more than direct database access. The application host itself should be little more than a pass-through set of operations to be invoked.
At that point, you can create a second application host alongside the first one:
Client -> ASMX Service ----|
|-> Business Logic
WebAPI Service --|
So now you have two different services which expose the same business logic, using two different web service technologies. Each of them should be very thin, as application host technologies should always be easily replaceable.
At this point, assuming there are no significant gaps in the operations available between the two services, you can publish the new service's specifications to clients and begin plans to deprecate the old service. When you can deprecate it is more of a contractual issue than a technical issue. However long you've committed to maintaining it, that's how long clients will have a reasonable expectation to still use it.
If you really want to, you can even have the ASMX Service be a pass-through to the WebAPI Service, but in my personal experience that adds unnecessary layering to the whole setup and artificially complicates the abstraction of the business logic. Either way, the interface exposed by the ASMX Service wouldn't change.
The main thing here is the logical abstraction of the operations being exposed and the analysis of any gaps between what the ASMX Service can do and what the WebAPI Service can do. If that gets complex, then that's an indication that the business logic (and indeed the whole solution domain) is tightly coupled to the application technology being used, namely ASMX web services. That is the problem to be solved. Once solved, creating different application hosts and exposing different services which invoke the same underlying business operations becomes almost trivial.
You are right; you are stuck if you can't change the client and you want to change service protocols. Your client currently has a specific .asmx endpoint it is configured to point to and until you can update that endpoint and have the client stop using the proxy generated from the service, you can't change to Web API.
I'd still rewrite the service to use EF, though.
So this is in relation to my question here.
So I have an existing wcf service running already, hosted on IIS. I created a Router Service that will do some XPath filtering on the header. So if the header is match then go to service1.
Now, I hosted my Router Service on IIS and I can access it like http://iis.com/myrouter/router.svc/ and give me this wsdl stuff. Now when I try to request a service method on service1 like this http://iis.com/myrouter/router.svc/general/getMyMethod?blah=blahblah. It gives me a 404 error. I used fiddler by the way.
On my request through fiddler I added my custom header like "service_version:1". I used a namespace by the way on my <namespaceTable> but I don't know how to append it on my request. Anyway, my main concern is how can I make my Router Service work on IIS?
Update: I am using System.ServiceModel.Routing.RoutingService by the way. So what I am trying to accomplish is Routing Services.
Your help is greatly appreciated.
You are likely facing this. A SOAP service can't be accessed that way because it relies on the SOAP package. Here is another article that should lead you down the right direction. However, the direction it leads you down is that testing a SOAP service by hand is not to be desired and probably a futile effort.
However, one note is that it leads you to use the WCF Test Client - that's the best direction to go my friend and it's very easy to use. Provide the URL and it will do the rest.
Invoke soap wcf service in Fiddler like in Wcf test client
Accessing the RESTful Endpoint
If you're trying to test the RESTful endpoint then the issue is likely surrounding the routing that is configured. Please refer to this link for assistance - make sure you're setting up your service the same because the attributes they use build the routing properly. Remember that you're not going to reference the RESTful endpoint with the same address as the SOAP endpoint.
http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx
You can also check out this link.
Hosting WCF soap and rest endpoints side by side