Solved

Class Instantiation

Posted on 2011-09-07
4
265 Views
Last Modified: 2012-06-27
Dear all

As I am not uptodate with new technology :-)
I need to create an instance of the class below and call the method  <<public DownloadFile[] GetProcessProtocol>>
and print the result in a console... using Window Console project..

a snippet of the <<  static void Main(string[] args) >> declaration will be appericated..

Thanks in advance
public partial class CallerDownloadServices : System.Web.Services.Protocols.SoapHttpClientProtocol
	
	 public DownloadFile[] GetProcessProtocol(string CallerID, System.DateTime CreateDate, bool ArchiveData) {
        object[] results = this.Invoke("GetProcessProtocol", new object[] {
                    CallerID,
                    CreateDate,
                    ArchiveData});
        return ((DownloadFile[])(results[0]));
    }
	
	 public DownloadFile[] Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((DownloadFile[])(this.results[0]));
        }
    }

Open in new window

0
Comment
Question by:ZURINET
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
yesthatbob earned 500 total points
ID: 36497892
This would depend on what the DownloadFile class looks like. That's the only way to know how you would print the value of what is returned by CallerDownloadServices.GetProcessProtocol(). However, let's say for argument's sake that there is a ToString() method on the DownloadFile class that returns the value you would want to print. You code should look like this.

static void Main(string[] args)
{
	string callerId = "your caller ID here";	// you'll need to set your caller ID value
	DateTime createDate = DateTime.Now;		// you'll need to set your create date value
	bool archiveData = true;			// you'll need to set your archive data flag
			
	// Create an instance of CallerDownloadServices
	CallerDownloadServices dlServices = new CallerDownloadServices();

	// Call GetProcessProtocol to get the DownloadFiles
	DownloadFile[] dlFiles = dlServices.GetProcessProtocol(callerId, createDate, archiveData);

	// Cycle through the DownloadFiles to get each value
	foreach (DownloadFile file in dlFiles)
	{
		// Print each value to the console
		Console.WriteLine(file.ToString());
	}
}

Open in new window

0
 

Author Comment

by:ZURINET
ID: 36497972
Hi bob

Thanks for prompt reply

attached is the download class

How will the code look like then?
public partial class DownloadFile {
    
    private byte[] dataField;
    
    private string filenameField;
    
    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
    public byte[] Data {
        get {
            return this.dataField;
        }
        set {
            this.dataField = value;
        }
    }
    
    /// <remarks/>
    public string Filename {
        get {
            return this.filenameField;
        }
        set {
            this.filenameField = value;
        }
    }
}

Open in new window

0
 
LVL 4

Expert Comment

by:yesthatbob
ID: 36498085
Depends...do you want to print the file contents, of the filename?

If it's the filename, simply change line 17 in my example to:

Console.WriteLine(file.FileName);

Open in new window


If it's the contents (Data property), things get a bit trickier, because the data could be binary and not play well when printed at the console.
0
 

Author Comment

by:ZURINET
ID: 36498127
Thanks...
Just want to make sure that I can access the Webservice....
The file will be passed on to a customer..

Thanks once again
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

830 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