2012-03-16 73 views
0

我试图连接到网关服务:连接到网关服务

的服务说,这时候我“添加Web引用”它说的服务:

HTML文档不包含Web服务发现信息。

网关服务显示了这个:

您已经创建了一个服务。

要测试此服务,您需要创建一个客户端并使用它来调用该服务,以便 。

svcutil.exe的http://xxxxxxxxxxxxxxx.com/API/Gateway.svc?wsdl

这将生成一个配置文件,包含 的代码文件:您可以使用svcutil.exe的工具从以下语法 命令行做到这一点客户类。将这两个文件添加到您的客户端应用程序,并使用生成的客户端类来调用服务。例如:

C#

类测试{ 静态无效的主要() { GatewayClient客户=新GatewayClient();共享子主() 昏暗客户端作为GatewayClient =新GatewayClient

// Use the 'client' variable to call operations on the service. 

    // Always close the client. 
    client.Close(); 
} } 

的Visual Basic

类检验 () '使用 '客户' 变量来调用服务操作。

' Always close the client. 
    client.Close() 
End Sub End Class 

于是,我尝试连接到这个代替:

http://xxxxxxxxxxxxxxx.com/API/Gateway.svc?wsdl

这给了我下面的列表:

方法AddABAccount()CloseBatch()CopyVaultAccount() ProcessAccount()ProcessCustomer()ProcessCustomerAndAccount() 进程交易()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!?

+0

您在编译时得到_Cannot解析symbol_错误,是否正确? – 2012-03-16 19:07:32

+0

在我尝试编译之前,我在视觉工作室中获得它。 – ErocM 2012-03-16 19:09:03

+0

你创建它时给你的服务提供了什么名字? – 2012-03-16 19:10:05

回答

1

当添加Web参考您试图添加对旧式.asmx Web服务的引用。

您实际尝试引用的服务是WCF Web服务 - 在添加服务引用时从Visual Studio 2008开始WCF Web服务是首选选项(您将需要挖掘某些“高级”选项以添加.asmx Web服务)。

要使用为您创建的Web Service客户端代理,请确保在您的using语句中包含名称空间。

,它是将服务引用时是“ServiceReference1”,因此增加

using ServiceReference1; 

应该解决您的问题设置的默认命名空间。

+0

啊,这有帮助!我将它添加为Web引用而不是服务方法。一旦我做到了,它就添加了拨出的dll。对Web服务的引用在那里,但没有正确添加。谢谢! – ErocM 2012-03-16 19:25:23