【发布时间】:2012-03-16 18:59:25
【问题描述】:
我正在尝试连接到网关服务:
当我向它说的服务“添加 Web 引用”时,服务会这样说:
HTML 文档不包含 Web 服务发现信息。
网关服务显示如下:
您已经创建了一个服务。
要测试此服务,您需要创建一个客户端并使用它来 致电服务。您可以使用 svcutil.exe 工具从 命令行语法如下:
svcutil.exe http://xxxxxxxxxxxxxxx.com/API/Gateway.svc?wsdl
这将生成一个配置文件和一个代码文件,其中包含 客户端类。将这两个文件添加到您的客户端应用程序并使用 生成的客户端类调用服务。例如:
C#
类测试{ 静态无效主要() { GatewayClient 客户端 = new GatewayClient();
// Use the 'client' variable to call operations on the service. // Always close the client. client.Close(); } }Visual Basic
类测试 共享子主() 昏暗客户端 As GatewayClient = New GatewayClient() ' 使用 'client' 变量调用服务上的操作。
' Always close the client. client.Close() End Sub End Class
所以,我尝试连接到这个:
http://xxxxxxxxxxxxxxx.com/API/Gateway.svc?wsdl
这给了我以下列表:
方法 AddABAccount ( ) CloseBatch ( ) CopyVaultAccount ( ) ProcessAccount () ProcessCustomer () ProcessCustomerAndAccount () ProcessTransaction () ProcessVaultTransaction () UpdateABAccount ( )UpdateABSchedule()UpdateTransaction()
所以,我可以添加它...
但是,当我按照他们的建议尝试在代码中连接到它时:
GatewayClient Client = new GatewayClient("wsBinding");
TRANSACTION oT = new TRANSACTION();
GATEWAYRESPONSE oGr = new GATEWAYRESPONSE();
oT.AMOUNT = 1;
oT.TEST = "FALSE"; // When testing, use TRUE
oT.METHOD = "CC"; // We'll use a credit card
oT.ORDERID = GetOrderID(); // Define a unique id for each transaction
oT.CODE = "0000"; // An Auth only transaction
//Process the Transaction
oGr = Client.ProcessTransaction(oT);
//Close the Client
Client.Close();
if (oGr.TRANSACTIONRESPONSE.RESPONSE_CODE == "1")
{
//Handle approved transaction
}
else if (oGr.TRANSACTIONRESPONSE.RESPONSE_CODE == "2")
{
//Handle declined transaction
}
else
{
//Handle transaction error
}
我无法访问 GatewayClient,它说:
无法解析符号“GatewayClient”
在哪里可以找到 GatewayClient!?
【问题讨论】:
-
您在编译时收到 Cannot resolve symbol 错误,对吗?
-
在我尝试编译之前,我在 Visual Studio 中得到它。
-
您在创建服务参考时给它起什么名字?