英文:
Connecting Visual Basic to C# WCF
问题
这是我已经完成的部分:
- 右键单击以添加服务引用。
- Visual Basic 创建了一个名为
App_WebReferences
的文件夹,其中包含ServiceReference1
文件夹。在ServiceReference1
文件夹内,它包含了Reference.svcmap
文件。 - 在
Reference.svcmap
文件内,包含了更多带有扩展名.svcinfo
、.disco
、.wsdl
、.xsd
的文件。
我该如何从我的 Visual Basic .aspx.vb 网页表单中调用 WCF 操作契约?
英文:
I have some services built with C# WCF and this service is self-hosted. My main application is built with visual basic and with the .NET Framework. I have a webform in .aspx.vb
and I want to connect to the services in C# WCF.
This is what I have done:
- Right-click to add service reference.
- Visual Basic created a
App_WebReferences
folder withServiceReference1
folder. Inside theServiceReference1
folder, it contains theReference.svcmap
. - Inside the
Reference.svcmap
, there are more files with the extensions.svcinfo
,.disco
,.wsdl
,.xsd
.
How do I call the WCF operation contracts from my Visual Basic .aspx.vb web form?
答案1
得分: 1
以下是翻译好的部分:
服务器和客户端的语言差异通常不会产生很大影响。因为您发送带有参数的请求给服务进行处理,它只会返回给您一个结果。
例如:
我有一个用C#编写的WCF服务:
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
客户端代码:
Module Module1
Sub Main()
Dim client As Service1Client = New Service1Client()
Dim result As String = client.GetData(1)
Console.WriteLine(result)
Console.ReadLine()
End Sub
End Module
英文:
The difference in the language of the server and client generally does not have a big impact. Because you send a request with parameters to the service to process, it will only return you a result.
For example:
I have a WCF service in C#:
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
Client code:
Module Module1
Sub Main()
Dim client As Service1Client = New Service1Client()
Dim result As String = client.GetData(1)
Console.WriteLine(result)
Console.ReadLine()
End Sub
End Module
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论