Groups | Blog | Home
all groups > dotnet web services > january 2005 >

dotnet web services : Cannot Convert from ..CreditCardInfo to ..MyWebService.CreditCardI


Seli
1/25/2005 2:57:01 PM
Hello I have a BusinessClass CreditCardInfo defined in a library:
namespace Cockpit.TrackingLibrary
{
/// <summary>
/// Summary description for OPCSignal.
/// </summary>


[Serializable]
public class CreditCardInfo
{
private string _number;
private int _expMonth, _expYear;

public string CardNumber
{
get { return _number; }
set { _number = value;}
}

public int ExpirationMonth
{
get { return _expMonth; }
set { _expMonth = value;}
}

public int ExpirationYear
{
get { return _expYear; }
set { _expYear = value;}
}
}

I have a webService using this BusinessClass as Parameter:
namespace Cockpit.TrackingLibrary.wsOPCTransmitter
[WebMethod()]
public void MakeDebit(CreditCardInfo ccInfo, float amount)
{
// ... process the credit card ...
}


In the client I try to to call this Webservice:

srvOPCTransmitter = new wsOPCTransmitter.srvOPCTransmitter();
// create an instance of the CreditCardInfo object
CreditCardInfo cc = new CreditCardInfo();
cc.CardNumber = "1111222233334444";
cc.ExpirationMonth = 2;
cc.ExpirationYear = 2005;
srvOPCTransmitter.MakeDebit (cc,4.95F);

but the compiler says at line with MakeDebit:
cannot convert from Cockpit.TrackingLibrary.CreditCardInfo to
Cockpit.TrackingLibrary.wsOPCTransmitter.CreditCardInfo


It seems it excpects the proxy class insted of the BusnissClass in the Web
Service Call!!!??

Waht is wrong?
Has anybody an example in C# with using an BusinessClass as Parameter in a
WebMethod?

Thanks
Seli

Dilip Krishnan
1/25/2005 4:34:24 PM
Hello Seli,

I believe you are trying to share types... refer the post titled "two
references to the same class in WebService client problem" in this news group

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

[quoted text, click to view]

erymuzuan
1/26/2005 8:31:46 AM
Look at the generated proxy, use(if you use "Add web reference" from
within VS.Net, it's hidden .. so view all files .. expand the web
reference ), now for the services you'll have CreditCardInfotype ,remove
the CreditCardInfo class definition in the proxy.. and replace all
intance of Cockpit.TrackingLibrary.wsOPCTransmitter.CreditCardInfo to
Cockpit.TrackingLibrary.CreditCardInfo in the proxy methods parameters.
BTW with .Net 2.0 you can use /sharedtypes to automatically enanble this.

regards
erymuzuan mustapa

[quoted text, click to view]
AddThis Social Bookmark Button