How to use web service methods in ssrs? - c#

I am new to the SSRS i have created a web service which has one method which takes the string value and returns image of bar-code of that value method is as below
Image BarcodeText(string textToBarcode,int barcodeWeight,bool isMargin)
i want to call this method in my SSRS report from the web service in the image box expression and pass the value to the method i don't know how to call a method from the web service. I searched for accessing method from the web service but came up as no help so any links or any description would really helpful for,
1) How to reference web service in the report ?
2) How to call method from web service and pass the parameters to the method ?
Thanks in advance.

I have got same problem some time back so i got a work around for this problem i hope this will work for you too.
1) First i created the web app with the service reference of the created web service suppose Barcode39 is service so add the reference to the web application.
2) Then write the code behind using service client and call the method to create the barcode image in that code by passing the request variables values
3) Now give the link of that page as the URL to the image expression along with setting the image type as "EXTERNAL" and pass the values to the URL as request variables as
"http:\\localhost:2310\BarcodeImage.aspx?data=" +(Parameters!YourParamtere.Value)
And one thing instead of returning the Image from the service try returning the byte array using stream and .ToArray() method that would be the best practice.Let me know if any problem.

http://technet.microsoft.com/en-us/library/aa964129.aspx
This webpage give you all the info you need for accessing web service from SSRS.

Related

IndexOutOfRangeException when creating an Extension Codeunit for a Page Web Service

I'm trying to expose a Function in a Codeunit through a Page Web Service in Dynamics NAV (2009 R2). I followed the MSDN documentation and the steps in a blog post, but I'm getting the following error when connecting to the Web Service:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
I've created a Page Web Service and a Codeunit Web Service, both using the same name, with only the Page Web Service published:
My Codeunit contains only 1 Function for the moment and looks like this:
When I publish the Codeunit Web Service as well, I can use it, but the Page Web Service still shows the error.
When I rename the Codeunit Web Service, the Page Web Service works again as before, without the Codeunit's Functions, of course.
Am I missing something or doing something wrong?
Function in your codeunit have wrong signature. Moreover in the blog it is Run function that is used (not user function). Don't know if it's matters.
Next phase: post the selected invoice. I don't have a method in my web service to post my invoice, so this is where we are going to extend the web service with this possibility. Very simple! I just created a codeunit with a function. In this function, the signature is important: the first parameter should be the same record variable of the page you published (in our case, "Sales Header"). This is my (only) function of my codeunit:
PostInvoice(precSalesinvoice : Record "Sales Header")
CODEUNIT.RUN(CODEUNIT::"Sales-Post", precSalesinvoice);

How to call a Rest Webservice and return json string in c#.net

I created a Rest Webservice with WebApi. This have 4 HTTP verbs. That is Get,Post,Put,Delete.
I want to call all these methods in webservice in C# window form application. It is not possible to add service reference for this Webservcie. How could i call GET,Post,put and delete method? I want to pass json string with POST request. Please help
If you just want to call the service and pass along the POST data manually, and also manually parse the results, you can use System.Net.Http.HttpClient.

Web services to validate the canadian address through purolator webservice

Hey I am trying to use Purolator Web services to validate the address.
I already included web services in my project and have all credential to communicate but I don't know how to validate through web services and it's my first time that I am using web services please help
I am using C#
I have three input field to asp.net to validate
city
Postcode and
province
If someone can give me details info how to this validation through web service I will really appreciate their help.
Please give some sample code how can I do this
already included reference
using com.purolator.devwebservices;
com.purolator.devwebservices.ValidateCityPostalCodeZipRequestContainer;
This is how it show in their documentation.
I like to upload the picture to show you the web service request and response diagram but I don't have privileges
ValidateCityPostalCodeZipRequestContainer
ValidateCity PostalCodeZipRequest
tns:RequestContainer (extension)
tns:Addresses SenderA ddress - ShortAddress[]
tns:ArrayOfShortAddress
tns:ShortAddress
tns:ShortAddress
tns:City City -string
tns:Province Province - string
tns:Country C ountry - string
tns:PostalCode P ostalC ode; - string
In order to call the webservice, you first have to add a web reference, which you already did, now you need to instantiate the object of proxy class which from your post i believe is ValidateCityPostalCodeZipRequestContainer and call the RequestContainer method of object with required parameter to validate the address.
* Answer above is based on my assumptions becuase I don't have any information about the webservice. If you can post WSDL then I can give a precise answer.
Between, according to Purolator's website there are number of sample available here: https://eship.purolator.com/SITE/en/content/developmentprocess/websservicesprogram.aspx
May be you can find one using asp.net
And by the way there is a nice tutorial given here for consuming webservices in asp.net: Calling Web Service using ASP.NET.

Problem passing parameters to WebService asp-net C#

Hi everyone let me explain this issue:
Background:
I have two web applications
The first one exposes some web services (server_wapp).
The second one consumes them (client_wapp).
I added a new web service to the server application that takes two strings as parameters, and it work OK using it directly form the .asmx page (new_ws).
Problem:
When I call the new_ws from the client_wapp all the parameters have their right content, but when the method is executed in the server_wapp, one of its parameters is passed as null.
Somthing link this:
In client_wapp I have server_wapp.new_ws("string1", "string2") and it gets executed in server_wapp as new_ws("string1", null).
I already rebuilt both web applications, but the problem remains.
Any ideas/comments?
Thanks in advance!
Update the link to server_wapp so that the proxy source code will be re-generated. WebService is usually used by adding reference to webservice url, and everytime you do some modifications in the webservice, its should be updated.

Can I get the URL used from the stub class created with wsdl.exe?

I'm working with a customer whose web service doesn't return the data in every case. Since the C# stub code is generated by calling wsdl.exe, I'm wondering how to get the actual URL used for any particular method call. I would like to feed the URL to a browser to show them (aka point fingers).
You can set the URL property on your service object? Is that what you mean?

Categories