Rhino Mocks for ASMX Web services - web-services

How do you mock old web services (not WCF) with Rhino Mocks, I can find plenty on WCf but not the old ones?

To mock a Web Service, you have to extract an interface from the generated web service code (reference.cs), and make the web service code inherit from that interface. You could make the web service "reference.cs" implement the interface, but may kill that code when you "update web reference". The trick is to add a second "partial class" that will inherit from that interface.
Then you mock the interface, Gah, why didn't i think of this earlier

Related

If I can write HTTP Service in WCF, why should I use Web API?

I've gone over other WCF vs Web API question as well as blogs. It is possible to write HTTP service with webHttpBinding in WCF too. So why should one move to Web API when it is possible to use WCF for the same purpose. Some say it's easy to use HTTP in Web API. But in what sense.
A lot of blogs make me confused. Most of them are like " You can do HTTP in WCF but Web API is pure REST based. You can use Web API if you want but you can use WCF too". It's like salesman describing their product which is really confusing for me here.
I have old asmx service which I want to move to REST Service. I tried WCF with webHttpBinding. It works well but why should one move to Web API?
If you already have a WCF service that you're satisfied with, then you're done. No need for WebAPI.
You would use WebAPI if there are features of the WebAPI which WCF cannot conveniently supply. The WebAPI is "closer to HTTP", whereas WCF is a generic communications framework.

Hibernate RESTful webservices in NetBeans

Is it possible to create RESTful Web Service using Hibernate in Netbeans 7.4?
I could see wizard to create RESTful Web Service using Persistence, but would like to know how it can be integrated with Hibernate?
Appreciate any help or insight.
Edit 1
I would like to know what I did is the correct method of generating RESTful web services using Hibernate.
First I generated Hibernate Entity classes using NetBeans and then I created RESTful services from Entity classes. So does this creates RESTful Web Services with Hibernate? I could see AbstractFacade classes that is almost like DAO classes
Edit 2
Screen shot for selecting RESTful Web Service from Entity classes
If you want to build a truly RESTful service, you need to build up a link relation architecture. You're going to need more than Hibernate or Netbeans to do that.
I recommend using the milestone Spring Data REST in conjunction with Hibernate's JPA implementation and Spring HATEOAS. See Spring Restbucks as an example which brings all these technologies together.

Should I mock external web service if my code's sole purpose is to talk to this web service?

I am creating an sdk/client library for a web-service. I understand mocking external dependencies etc using things like wiremock for http. But should I mock the external web service if my code's sole purpose is to talk to this web service? Or should I create two separate test suites - unit testing with mocked out services and another set that perform the full integration tests?
Mocking the external web services make sense. I have used it for Unit Tests alone. It is acceptable practice.

Calling a web-service via NHibernate

We have a webservice that is created to perform database operations. The service is created in JAVA with Hibernate.
Can we use NHibernate to access that java service in our .Net code?
I think you kind of misunderstand what NHibernate does. It is just a library that facilitates database access. It's not because your webservice uses hibernate internally that you need NHibernate in the .net part. Actually, with a webservice, you're not really interested in the internal workings of the webservice. You're just interested in what the webservice exposes: the contract.
If you want to consume that contract in your .net code, you should be looking at a WCF client

EJB 3 | Entities with webservices

I want to access a inventory system which is accessible through webservice, What is the best way to integrate, I thought of directly expose the entity facade as a web service using #WebSerive it's possible but don't know whether it's a good approach or not, need some advice.
Thanks.
You could eventually define the methods to be exposed in the same class (or maybe create a wrapper).
My understanding is that you want to consume a web service i.e. to implement a web service client. My recommendation would be to use JAX-WS for this. See :
A Simple JAX-WS Client in the Java EE 5 Tutorial
Developing JAX-WS Web Service Clients