Question

I've inherited a WSDL file for a web service on a system that I don't have access to for development and testing.

I need to generate a web service that adheres to that WSDL. The wrapper is .NET, but if there's an easy way to do this with another platform, we might be able to look at that. The production web service is Java-based.

What's the best way to go about doing this?

Note: The inherited wsdl doesn't appear to be compatible with wsdl.exe because it doesn't conform to WS-I Basic Profile v1.1. In particular, the group that passed it on mentioned it uses another standard that the Microsoft tool doesn't support, but they didn't clarify. The error is related to a required 'name' field:

Error: Element Reference '{namespace}/:viewDocumentResponse' declared in
schema type '' from namespace ''
       - the required attribute 'name' is missing

For clarity's sake, I understand that I can easily create a .NET wrapper class from the WSDL file, but that's not what I need. It's like this:

Update: The original web service was created using Axis.

Diagram of system showing unavailable web service and mock web service http://paulw.us/blog/uploads/SO-WSDL-Question2.gif

Was it helpful?

Solution

We are using WSCF - Web Services Contract First tool from Thinktecture to do web service development creating XSD schema first and then generating service interfaces using this tool. It may be useful to generate service interfaces from WSDL but I have not tried this yet myself.

OTHER TIPS

You may find useful the command line utility wsdl.exe of .NET by using the /serverInterface option. According to the documentation:

Generates interfaces for server-side implementation of an ASP.NET Web Service. An interface is generated for each binding in the WSDL document(s). The WSDL alone implements the WSDL contract (classes that implement the interface should not include either of the following on the class methods: Web Service attributes or Serialization attributes that change the WSDL contract). Short form is '/si'.

Yes - you can use WSCF (as per above) to generate server side code. The actual URL can then be overwritten to point to the test URL that you want to use.

However, this just generates a stub. You still have to code the actual e.g. GetCustomers() method which is somewhat suspect because you have no idea how the actual implementation works.

Then you can either mock this or create a simple ASP web server to run it.

Try mock the wrapper interface using RhinoMocks and StructureMap .

Not sure if this will help,

what i've done recently is:

  • Generate .cs file using the wsdl tool or visual studio
  • I've changed it to be a partial class
  • I've created another partial class, in which all it does is add a line to say that the class implements IWhatEver
  • I've created an interface that is the same as the generated proxy class (Therefore the the proxy fully implements the interface)

Then i've used a Mocking framework (Moq) in my case, to mock the WebService, I've then used poor mans dependancy injection (pass the mock into a constructor of the class under test) .. which can handle an instance of IWhatever

Test away..

Hope that helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top