Wsdl, test web service, newbie - asp.net

I have a few wsdl URLs (e.g. https://location?wsdl). And I need to automate the testing of these web services with asp.net. How can I do that ? I was told that http website request could do this (HttpRequest Class). I don't know much about web services except the basics.

Create a unit test project. Use "Add Service Reference" to reference the WSDLs within this project. Then, just create unit tests to call the service and confirm that the results are as expected.
Note that purists will say these are integration tests, not unit tests, but that's ok. They'll be automated, which is what you were looking for.

Soap UI works great if you can get around the requirement of having to using ASP.NET.
See the tutorial here...
http://www.soapui.org/Getting-Started/your-first-soapui-project.html
If you have to use .NET why can't you just make a proxy class of the webservice using wsdl.exe and then test it with the web service client that's generated from that?

Related

WebApp Proxy to APIGEE

We have a legacy "Web application" that uses traditional J2EE MVC architecture. The web application is like a thin proxy that does request validation and transformation, calls back-end services, and finally transform the response payload before returning it to the caller. We are planning to move this application to the APIGEE. Since most of my web app code is written in Java, I am planning to use Java callout to perform everything that is being done in my existing "Web App". What I wanted to know is - Are there any other way to migrate the "Web App" logic in the APIGEE proxies? Any experiences you can share?
Depending on the complexity of the transformations necessary, you can refactor to use Apigee native mediation policies and JS, maintaining the JS code directly inside a JS policy in the proxy package. Else call-out to proper Java. It might be lower effort in the short-term to just hang onto your Java and call-out to it, but you may find better performance in the long term if you refactor.

Best Solution for Tracing/Loging Web Service

We have ASP.NET 4.5 web services (asmx) with a lot of projects and classes.
We need to recreate bugs in production enviroment so if a bug is reported we would like to view a log file so we can recreate the bug.
It will be a lot of work to write logger code lines in the solution projects.
Is there any logging add-in/extension that will do the work more rapidly?
We use WCF Message logging. It logs the entire xml that is sent into the web service.
If we have a problem in test or Production, we take the xml, put it into SOAP UI and run it against the web service. This Works well for stateless calculation services, for services that require state you could take a copy of Production to recreate the problem in test.
Here is how you can configure it: https://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx

Calling WCF service from jsp page

I have created a WCF Service and published it to a Windows Server running IIS. In an asp.net web application, I can add a Service Reference to the WCF Service which exposes its methods which I can call. This all works fine.
I need someone who is running a jsp site to be able to call a method in my WCF Service. How can they do that? (I know absolutely nothing about jsp). Presumably they cannot reference my WCF Service within their application in the same way you can within a .net application.
The web services are totally platform independent. Therefore, someone writing in Java should have no problem calling a web service server, regardless if it was written using WCF or another platform. For example, here, here and here you could find some tutorials on how to build web service clients using java. This java code could be called from JSP pages.
If you want to quickly test your web service from the client side, you could use SoapUI. It's a web service client tool developed in java. I am sure you will find it useful.
Hope I helped!

How and Why to Create a webservice?

I have a small routine that programmatically builds an XML file that resides in memory based on a dataset that I send to the routine (it's called CreateAdXML()).
My buddy says I should turn it into a 'webservice', but I'm not quite sure what he means or how to do that. Can someone offer me some pointers? Is it relatively easy to take existing code for an asp.net site and turn it into a webservice?
There are many possibilities to create web services for an ASP.NET application. It all comes down to what you actually need:
If you need secure connections, advanced serialization, WSDL support etc...
Go for WCF (http://en.wikipedia.org/wiki/Windows_Communication_Foundation)
MSDN : http://msdn.microsoft.com/en-us/library/vstudio/ms735119(v=vs.90).aspx
If you only to expose a few methods:
Go for WebMethods (that's deprecated + quick and dirty in my opinion)
WebMethod tutorial: http://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx
If you need to expose data through a standardized interface, interoperable and bandwith-friendly service (that's called REST):
Go for Web APIs
Official page: http://www.asp.net/web-api
There also a lot of webservices frameworks available on codeplex, do some research to see if one suits your need better. A few well known are RestSharp and ServiceStack.
My advice:
From what you described, I would go with WebMethods for test purposes only. Once you know more about the client that will consume you web service, chose one of the apropriate framework.
If however you need to expose more methods, you should consider using Web APIs or WCF from the start, since these are much cleaner web service frameworks. It will also make you service stack MUCH easier to maintain.
It sounds to me more like you need to make it a utility method instead of a web service, as this will allow all of your web project to use this functionality, but not necessarily expose it beyond the boundaries of your application.
If you insist on making it a web service, then read A Beginner's Tutorial for Understanding Windows Communication Foundation (WCF).
It is fairly easy to create web services from ASP.NET code (VB.NET/C# etc..)
You can use the following link to help you understand more about ASP.NET Web Services.
http://msdn.microsoft.com/en-us/library/t745kdsh(v=vs.90).aspx
HOW TO: Write a Simple Web Service by Using Visual C# .NET
But all of the other answers are good too.

How to consume web service in my application

While consuming a web service in my application I have two choices(ref. msdn)
Adding the Proxy Using the WSDL Tool
2.Adding the Proxy Using a Web Reference in Visual Studio
Now what should I choose, 2nd option is very simple and I generally follow that.
I want to know what are the pros and cons of both the options(if any) and ideally what should I choose?
Thanks.
They essentially achieve the same thing. The second gets the WSDL from the web service and generates the proxy, which requires the service to be online at the time.
Add the reference automaticly when possible, Visual Studio will do everything for you.
Under certain scenarios this is not possible. so you will have to do some manual work, like running the command to generate the proxy class and copying some configuration lines into the web.config manually.

Resources