Solved

convert windows client to web client

Posted on 2010-09-01
2
281 Views
Last Modified: 2012-05-10
i need help figuring out how to convert this windows client to a web client. My code from the web errors out at: fibertest = proxy.ListFiberTests();

Error:
Object reference not set to an instance of an object.

Question - wasnt that created at:  private System.Collections.ObjectModel.Collection<FiberServiceReference.FiberTest> fibertest = null;

Any suggestions?
Windows client code
private System.Collections.ObjectModel.Collection<FiberServiceReference.FiberTest> fibertest = null;
private FiberServiceReference.FiberTest[] fibertests = null;
private FiberServiceReference.FiberTestDetail fiberTestDetails = null;
private FiberServiceReference.FiberServiceClient proxy = null;

private void Form1_Load(object sender, EventArgs e)
{
proxy = new FiberServiceClient.FiberServiceReference.FiberServiceClient("WSHttpBinding_IFiberService");
}

private void listFiberTestsButton_Click(object sender, EventArgs e)
{
//get all rows of data
fibertest = proxy.ListFiberTests();

dataGridView1.AutoGenerateColumns = false;

DataGridViewTextBoxColumn idColumn = new DataGridViewTextBoxColumn();
idColumn.DataPropertyName = "FiberTestId";
idColumn.HeaderText = "Fiber Test Id";
idColumn.Name = "FTId";

DataGridViewTextBoxColumn workOrderColumn = new DataGridViewTextBoxColumn();
workOrderColumn.DataPropertyName = "WorkOrder";
workOrderColumn.HeaderText = "Work Order";

DataGridViewTextBoxColumn serialNumberColumn = new DataGridViewTextBoxColumn();
serialNumberColumn.DataPropertyName = "SerialNumber";
serialNumberColumn.HeaderText = "Serial Number";

dataGridView1.Columns.Add(idColumn);
dataGridView1.Columns.Add(workOrderColumn);
dataGridView1.Columns.Add(serialNumberColumn);

dataGridView1.DataSource = fibertest;
}

--------------------

web client
private System.Collections.ObjectModel.Collection<FiberServiceReference.FiberTest> fibertest = null;
private FiberServiceReference.FiberTest[] fibertests = null;
private FiberServiceReference.FiberTestDetail fiberTestDetails = null;
private FiberServiceReference.FiberServiceClient proxy = null;

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
proxy = new FiberMossClient.FiberServiceReference.FiberServiceClient("WSHttpBinding_IFiberService");
}
}

protected void btnListFiberTests_Click(object sender, EventArgs e)
{
//get all rows of data
fibertest = proxy.ListFiberTests(); //*** Errors here

grdvwFiberTests.AutoGenerateColumns = true;
grdvwFiberTests.DataSource = fibertest;
grdvwFiberTests.DataBind();
}

Open in new window

0
Comment
Question by:vicomin
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 33582521
Your real problem is line 9
proxy = new FiberServiceClient.FiberServiceReference.FiberServiceClient("WSHttpBinding_IFiberService")
the proxy object is not initialized.

Are you using WCF to generate the web service. In WCF, you only need to do something like:
proxy = new FiberServiceClient();
The autogenerated class and config file will take care of the rest.

I will strongly suggest to delete your current web service reference and add it again (On project menu click "Add Service reference". Al so make sure your webe service is working properly. check:
http://www.xvpj.net/2008/03/08/wcf-step-by-step-tutorial/
http://msdn.microsoft.com/en-us/library/bb332338.aspx
http://blogs.msdn.com/b/ericwhite/archive/2010/05/11/getting-started-building-a-wcf-web-service.aspx
0
 

Author Closing Comment

by:vicomin
ID: 33589954
yah changed it to proxy = new FiberMossClient.FiberServiceReference.FiberServiceClient(); and added it to each method.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Consuming WCF service from Java with callback contract 5 277
xml jquery 7 337
Image upload and format 1 105
SSL WCF Service Issues - Value cannot be null 6 79
In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question