http://example.com/ShaktiERPService/UpdateErpSrvc.svc?wsdl
i have one wcf service URL similar to above url... where i written one method (UpdateData) with 4 parameters. And this method is returning a string as response like "successfully updated" or "failed to update"
[ServiceContract]
public interface IUpdateErpSrvc
{
[OperationContract]
[WebGet(UriTemplate = "UpdateData/{Erp_Ord_No}/{SFDC_Order_No}/{usr}/{pass}")]
string UpdateData(string Erp_Ord_No, string SFDC_Order_No, string usr, string pass);
}
and My method is here:
public class UpdateErpSrvc : IUpdateErpSrvc
{
public string UpdateData(string Erp_Ord_No, string SFDC_Order_No, string usr, string pass)
{
ServiceRepository repo = new ServiceRepository();
return repo.UpdateData(Erp_Ord_No, SFDC_Order_No, usr, pass);
}
}
This service is working perfect in project...
But i want to check this in postman & fiddler....
I don't have any idea to check..
I tried so many time but didn't get response...
So please help me related to this problem..
Hope this helps you,
Fiddler is debugging tool.
Postman is best suitable to test your Web API methods. It can also be
used against 3rd party APIs and Open .
So, if your web service is with RESTful properties you can go with Postman to test the functionality of your web service.
However you can have fiddler in parallel to check the Request and Response in various formats such as
Normal Headers
without any extra effort.
Also, POSTMAN helps you to easily add the header fields , data, etc with Sophisticated User Interface when compared to Fiddler
Update 1:
As per your sample Code you are trying to using a GET request which works absolutely fine, how ever not a recommended standard.
Also, would like to know if your using Entity Framework for accessing the data, if so update your post with the necessary code to help you further.
You can use SOAPUI to test for WCF services. Check https://www.soapui.org/
to download. You can easily put your wsdl address and can just run your request.
Why don't you use WCFTestClient for checking your WCF service. It would clearly show you the request and response in XML format.
Related
For some days now i have been struggling on a project where i need to provide a URL to enable me to receive a JSON response(precisely this my first time of calling a web API)
This is the scenario:
- First the company has a web service that i need to consume and send a bill prompt to our client and so far it has been successful
- Second , they ask me to implement a callback and give them the URL where they will call me to send the status of the bill whether our client has confirm the bill prompt or not(this is where i am stacked)
When i get the JSON data i can easily use it to do what i want but my problem is how to implement the web page that the company will call to send the status.
Please a sample code will help me a lot.Thanks
What you are trying to achieve is called WebAPI. You expose HTTP endpoints using Controllers to the Internet and consumers of your API may utilize them to POST the status back.
You are describing creating an API. Basically, you create an endpoint url using a controller in C#. It's within this controller that you receive data from "the company" and process it, and do whatever you need to do after that. If you use the standard MVC framework build into C#, it's fairly straight-forward. Here is an example of a callback url we are using in a three-legged OAuth procedure. The last step involves a third party sending a request to our callback url and posting some data. We are using a model as a parameter. But you can use simple structures (int, string, etc) as well. As log as the names of your params match the names that the third party sends in their query string or POST, the MVC framework will handle the variable assignment automatically. The serialization/deserialization is built in to the framework.
Here is a small example of how we have implemented a callback url in one of our apps:
public class MyAuthenticatedController : Controller
{
public ActionResult Index([FromUri]MyAuthenticatedModel model)
{
logTheResponse(model);
if (model == null)
{
throw new HttpException(401, "Auth Failed");
}
}
}
The third party would hit the url:
http://app.mydomain.com/myauthenticated
Using the GET method.
If you don't want to build an ASP.NET Web API Project, you can do this easily with an Azure Function.
See: https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-generic-webhook-triggered-function
I have a WCF SOAP service with the following method:
[OperationContract]
string GetDetails(string param1);
Method GetDetails returns JSON string. I tested the method and it works as expected. When I run the service with WCF Test Client and pass in a parameter, it spits out a string in JSON format. But if I call the service from browser:
http://ServerName/projectName/ServiceName.svc/GetDetails/12345
I get an error Resource not found.
Can anyone explain what am I doing wrong?
Navigating to a URL in a browser performs a GET request on that resource. SOAP methods all use POST.
If you would test this with a program like Fiddler or Postman, you can test the different kind of HTTP methods like GET or POST. If you would perform a GET on your URL in fiddler you would get the same result as in the browser. Performing a POST would give you the same result as with the WCF Test Client.
I'm working on an Azure service for a Windows Phone app. I need the Azure Service to access the users' OneDrive. Following this article, my scenario should be:
The user sign in to Windows Live on the WP app.
The Live web service sends the authorization code to a redirect URI that I defined, with the code appended as a query parameter named code, as:
http://www.example.com/callback.php?code=2bd12503-7e88-bfe7-c5c7-82274a740ff
I get the authorization code and access the users' data
After investigating a lot in Service, I still can't find a way to capture the query parameter in my web service. As I am new to this area, I don't know where to focus on. I'll be really appreciated if you can give my an advise or answer my following questions:
Can I access the service just using the url with parameter in a browser? How can I see if the service is working properly?
An article mentioned using WCF [Web Get] attribute to get Query Parameters, but I still don't know how to implement both the IService1.cs and Service1.cs file, could you give me a sample about how to access the value of Query Parameter?
Thanks!
I'm not sure if i understand your problem properly but if you want your RESTfull WCF service to be the callback receiver for the request code, your Service must be hosted with a WebHttpBinding and a ServiceContract similar to this one.
[ServiceContract]
public interface IService
{
[WebGet(UriTemplate = "callback?code={requestCode}")]
void OAuthCallback(string requestCode);
}
So if the base address of your Service is "http://service.mydomain.com/MyService.svc" the OAuthCallback Method will be called when a http GET request to "http://service.mydomain.com/MyService.svc/callback?code=RequestCode" is made.
I am currently following this tutorial to create a simple REST service using Web Api. Note this is my first time doing something like this and I am just trying to learn more.
http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations
I have followed all the instructions and have it successfully running on my localhost. I understand that in this tutorial the URI for all my GET requests look something like:
localhostapi/products/id
And I understand that, and how to perform simple GET requests in the URI and see it actually occuring using my developer tools in my browser.
Now my question is... How do I make POST/DELETE/PUT requests and actually see what they are doing? The guide wasn't too clear, do I pass in parameters into the URI? Does the URI change when I want anything but a GET request? This text here seems to explain it but I do not understand:
The method takes a parameter of type Product. In Web API, parameters with complex types are deserialized from the request body. Therefore, we expect the client to send a serialized representation of a product object, in either XML or JSON format.
It's quite easy to make POST, PUT, DELETE requests. You just need to install Fiddler at http://www.telerik.com/download/fiddler
Next, install and run it. Go to the Composer tab on the right hand side. Next, put your local host URL, and the request method, and other data like the screenshot below
You can write unit tests, like
[TestMethod]
public void GetAllProducts_ShouldReturnAllProducts()
{
var testProducts = GetTestProducts();
var controller = new SimpleProductController(testProducts);
var result = controller.GetAllProducts() as List<Product>;
Assert.AreEqual(testProducts.Count, result.Count);
}
This link also This one may help.
more:
How to call ASP .NET MVC WebAPI 2 method properly
Sending C# object to webapi controller
You can set a breakpoint on your controller methods that handle the post/delete/put.
Same thing in your browser at the point where you call the post/delete/put (presumably in a jquery request)
You can also unit test your controller methods:
http://www.asp.net/mvc/tutorials/older-versions/unit-testing/creating-unit-tests-for-asp-net-mvc-applications-cs
I am required to consume a SOAP web service with a Java program I am writing. I have a basic test .NET service on my server in a .asmx file. There are a bunch of complicated examples that I found on Google but can someone provide a short explination for me? It would be greatly appreciated. Thanks!
Here is my .asmx file.
<%# WebService Language="C#" Class="Example1" %>
using System.Web.Services;
[WebService(Namespace="urn:Example1")]
public class Example1 {
[ WebMethod ]
public string sayHello(string name) {
return "Hello " + name;
}
}
Maybe there is a different way I should be doing this? Thanks again.
You can use a tool that comes with the JDK called wsimport to parse your WSDL file and generate Java classes.
wsimport http://path/to/your?wsdl -d /desired/output/folder
You can then use the generated classes like so:
Example1Endpoint example1 = new Example1Service().getExample1Port();
System.out.println(example1.sayHello("tkcsam"));
Is your .Net service a "page" that you post a string to as a parm? I've had to talk to a few of those in the past (I wouldn't really call them "web services", but anyway....).
If that is the case, find out what you need to post. Use your Java to build the giant String that you need to feed to the page and then send it to the page as a parm and wait for the response String coming back. You'll have to parse that string then.
This is terribly inelegant, but it used to be how Microsoft did things. Not sure if it is true in your case. Otherwise if you do have a WSDL to work with then I'd probably use either Jack's answer or follow the comment by djhaskin987 as there are some frameworks listed there that will dynamically generate web service clients based on published web services (that have their WSDL published with them).
JAXWS is the standard technology for interacting with SOAP webservices in java. the default implementation in the oracle jdk is the metro stack, which has an extensive user guide.