|
Before I pull out my hair out, throw the computer out the window, step on the neighbours cat, drive my car over the cliff or all of the above......I thought maybe I could ask for some help.
The concept is simple....or so it would seem.
I want to call a WebMethod with my credentials and get the information about my account back. Hmmm, should be a piece of cake. The problem is that the class created by wsdl.exe is an abstract class with abstract methods. So I created a class that implements those methods using override.
Here is the basic setup:
The abstract class created by wsdl
<br />
[System.Web.Services.WebServiceBindingAttribute(Name="AccountsSoap", Namespace="http://address")]<br />
<br />
public abstract class ServiceAccounts : System.Web.Services.WebService <br />
{<br />
<br />
[System.Web.Services.WebMethodAttribute()]<br />
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://address/QueryProfile", RequestNamespace="http://address", ResponseNamespace="http://address", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]<br />
<br />
public abstract AccountProfile QueryProfile(Credentials credentials);<br />
<br />
}<br />
The class to implement
<br />
[WebService(Name="ServiceAccounts",Description="Provides a callback mechanism",Namespace="http://address/accounts")]<br />
<br />
public class AccountsImpl : Project.App.Tls.Accounts.ServiceAccounts<br />
{<br />
<br />
[WebMethod(MessageName="QueryProfile",Description="Gets the profile of the specified client.",EnableSession=false)]<br />
<br />
public override AccountProfile QueryProfile(Credentials credentials)<br />
{<br />
}<br />
And finally the call
<br />
private void sendButton_Click(object sender, System.EventArgs e)<br />
{<br />
CredentialCache myCache = new CredentialCache();<br />
<br />
NetworkCredential netCred = new NetworkCredential("name1", "pwd1", "domain");<br />
((CredentialCache) myCache).Add(destUri, "NTLM", netCred);<br />
((CredentialCache) myCache).Add(destUri, "negotiate", netCred);<br />
((CredentialCache) myCache).Add(destUri, "digest", netCred);<br />
<br />
accounts.credentials.Account = "name2";<br />
accounts.credentials.Password = "pwd2";<br />
<br />
accountProfile = accounts.QueryProfile(accounts.credentials);<br />
}<br />
Now, I'm sure you are all wondering what my problem is....My problem is that I don't know what to put in my implementation of QueryProfile() to make it call the webMethod. All of the implementations I have seen say to create a new object of ServiceAccounts and then just call the respective method. This code I would put in my QueryProfile() implementation. But since both the ServiceAccounts and the ServiceAccounts.QueryProfile() are both abstract, I cannot create a reference to them.
I know the answer is going to be simple but I cannot figure this out!!!!!!!!
Any input would be appreciative as I kinda like my hair, my computer, the neighbour's cat and especially my car.
Thanks
SnowBlind37 who is CodeBlind37 at this moment
|
|
|
|
|
Hmmm...off the top of my head
try openning the ServiceAccounts class and removing the WebService base class as well as the attributes and the public and abstract modifiers from the methods the get an interface and using it that way?
|
|
|
|
|
I would love to modify the class to make it easier for me. The point is that this is the way it is and will be for other people that access this service(others have been able to do this successfully). My job is to find a way to do this easily and document the procedure. There has to be a way.
Definately CodeBlind37
|
|
|
|
|
|
I already am creating the AccountsImpl instance. But the AccountImpl.QueryProfile() still needs to return a value that will come from the webMethod QueryProfile(). This is a main part of the complication.
|
|
|
|
|
You guys are not going to believe this! When I ran my wsdl.exe I used the server option when I really wanted the client version. It all makes sense now.
I had been trying to look from the other side of an abstract class and could not find a way to make it work. And for good reason because an abstract class is designed to give you ways to implement methods with the same name but with different logic......Not to implement a method to use an abstract method to use varying implementations of a method
Talk about a trip outside the box. I will learn from now on to always take a walk around the box before I bang my head on the inside.
Feeling slightly less CodeBlind today.
Happy Coding All!!!!
|
|
|
|
|
I'm no expert in writing WebServices, but isn't AccountsImpl supposed to be the actual implementation of the QueryProfile web method? This is the code that's supposed to do work of querying the profile and returning an instance of AccountProfile, so how does calling it again solve the problem?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You are right Senthil! It is the actual implementation of the WebMethod. This is where I got stumped. It turned out that when I ran my wsdl.exe I specified "server". This gave me the server implementaion of the class which was an abstract class.
So on the server side there is an AccountsImpl that implements the abstract method QueryProfile(). This is the class that would do all the work for my call to QueryProfile().
But on the client side all I wanted/needed to do was create a ServiceAccounts object. So when I ran the wsdl.exe without specifying "server" (default is "client") I was given a ServiceAccounts class that was not abstract.
The problem then was that I had obtained (through wsdl.exe) the server implementation when I really needed the client implementation.
A valuable lesson was learned......and the best part is I still have some hair left, I didn't throw my computer out the window, I petted the neighbour's cat instead of stomping on it and my car is still in the driveway.
Regards,
Reserving CodeBlind For The Future..............
|
|
|
|
|
Hi folks!
I need to display video played by an external device (VCR, DVD player) in a .NET application. No need to record it, just generate a preview. How can it be done?
Thanks a bundle!
|
|
|
|
|
I have a class :-
namespace MyNamespace
{
public class MyClass
{
public void MyMethod ( System.SomeNamespace.SomeEnum test )
{
}
}
}
It would be nice to declare the enum in MyNamespace so the user of the class didn't have to remember which namespace the enum was defined in, ie something on the lines of :-
namespace MyNamespace
{
public enum MyEnum : System.SomeNamespace.SomeEnum ;
public class MyClass
{
public void MyMethod ( MyEnum test )
{
}
}
}
Is there a way possible without having to redefine all the enum values? Many thanks. Chris
Chris Davies
|
|
|
|
|
You can use the "using" statement (or directive, I forget how to name this usage) to do what you want.
namespace MyNamespace
{
using MyEnum = System.SomeNamespace.SomeEnum;
}
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Wow, cool, I thought this is only possible with classes...
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Many thanks, works a treat. Chris
Chris Davies
|
|
|
|
|
I made a ListView control on my program and I can see some code like this...
I want to change the size of a Column of ListView control when I resize my program widnows.
InitializeComponent()......
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.listView1.Alignment = System.Windows.Forms.ListViewAlignment.Default;
this.listView1.BackColor = System.Drawing.Color.Gainsboro;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,this.columnHeader2,this.columnHeader3});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(4, 120);
this.listView1.Name = "listView1";
this.listView1.Scrollable = false;
this.listView1.Size = new System.Drawing.Size(190, 50);
this.listView1.TabIndex = 5;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 70;
//
// columnHeader2
//
this.columnHeader2.Text = "Grade";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 40;
//
// columnHeader3
//
this.columnHeader3.Text = "Battle";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 100;
and...my_SizeChanged(object sender, System.EventArgs e)
{
this.columnHeader3.Width=this.listView1.Width-80;
this.listView1.Columns.Clear();
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,this.columnHeader2,this.columnHeader3});
}
what must I code above line?
Help me please.
I am going to make it. complete the vision.
|
|
|
|
|
Why are you removing the ColumnHeaders? Just set the according Width property and that's it.
Btw. you can also assign -1 or -2 to Width to adjust to header width or content width, resp. (can't remember which is which, just try it).
Regards,
mav
|
|
|
|
|
Hi
I have two set up installaation file and i want to merge both of them and make one set up file how can i merge both the .msi file
pls tell me complete procedure
everyone must have seen that while installating the dotnet cd its first seraches the windows up date product i.e service pack ,internet exploreer i also want to make first screen and give the user option for installing after the sleection of all the option which must be installled intiallay
pls tell me the c omlete path
Thanks & Regards
sanjeev
|
|
|
|
|
I'm subclassing the ColumnHeader (named MyColumnHeader for instance)
class and I want when I click the "Add" button in the Columns designer
window a MyColumnHeader object to be added to the collection, and not
a ColumnHeader object. I.e. I want to go round the writing of a custom
collection for MyColumnHeader items, 'cause it's too complicated.
Is this possible?
Thanks.
|
|
|
|
|
Hi,
I want to write a function that accepts a byte[]. The byte[] may be fairly large and won't be modified by the function.
What's the best declaration for this? Just declaring it as a normal byte[]? Or passing a "ref byte[]"? Const doesn't seem to work... readonly attribute?
One more question: when I pass a byte[], is this automatically modifyable? I.e. do changes in the function to the array affect the outer function, too? Must I mark it using ref in order to do so? (for normal variables I of course must, but byte[]?)
Thanks in advance and best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi
If you wanna your function don't change the value of array cells don't use 'ref' keyword ! This cause the parameter will pass by Reference !
I hope this was your answer
Always there is another way !
|
|
|
|
|
|
Passing it as a byte[] will pass the array by reference, as System.Array is a reference type. Because the array is passed by reference, the called function can modify the values in the array and the calling function will see the modified values. That is, if the called function looks like
void Test(byte[] byteArray)
{
byteArray[0] = 23;
}
then the calling function will get 23 when it indexes byteArray[0].
There is no way you can avoid this, the only workaround is to pass a copy of the data in the array.
However, the called function cannot change the array reference itsef. That is, if it does
void Test(byte[] byteArray)
{
byteArray = new byte[2];
}
then the calling code will *not* see the modified reference. If you want the calling code to see the modified reference, you need to add the ref keyword.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Ok.Sorry I misunderstand your question !
I think there is no way to pass reference types to functions like primitives in .NET ! .Net manipulate all reference types on the heap.If you can put the objects on the stack (Like Primitives) you must define your type by STRUCT !
.NET treat to structs like primitive types. Structs are same as classes,Except in a little differences in constructors !
I hope this was helpful for you.If you find another way,Please mail me !
Best Regards,
Always there is another way !
|
|
|
|
|
Maybe you wanted to address the original poster?
There are quite a few differences between structs and classes by the way, you can read more about it here[^].
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
What will "ref byte[]" pass then? The same as "byte[]" or some weird double pointer?
Read your reply again Clear now
Thanks!
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I really feel like a dumbass, but how do you create the .exe file that you would then distribute after coding. I have only coded C# in the web before so... Thanks
|
|
|
|