如何将请求发送到共享文件夹中的wsdl? (ASP.NET C#) [英] How to send request to wsdl, which is in a shared folder ? (ASP.NET C#)

查看:78
本文介绍了如何将请求发送到共享文件夹中的wsdl? (ASP.NET C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我构建了一个客户端应用程序。



我已经使用wsdl链接添加了服务引用。



现在,如何创建对象并发送请求?



我尝试了什么:



我必须使用2个字符串作为输入从WINDOWS CONSOLE APP向wsdl发送请求



任何帮助都会感谢

First I have built a client application.

I've added a service reference by using the wsdl link.

Now, how to create the object and send request ??

What I have tried:

I have to send a request to the wsdl from an WINDOWS CONSOLE APP using 2 strings as input

any help would be appreciated

推荐答案

如果您为端点的Web服务定义语言文件添加了服务引用,Visual Studio将生成一个代理,其中包含您给出的名称例如,你可以在一个using语句中新建一个。



所以说你的服务托管在一个控制台应用程序中,一个端点在本地实现IHWservice在http: // localhost:3000



这种提供自我主机的方式是使用和调试这种方式并将其移植到其他地方的最佳方式只有少数几个eps



if you added a service reference to the web service definition language file for the endpoint, visual studio will have generated a proxy with the name that you gave the reference, you can new that up in a using statement for instance.

so say you have your service hosted in a console app with one endpoint locally implementing IHWservice at http://localhost:3000

This way of providing a self host is the best way to work with and debug such and porting it to somewhere else is only a few steps

[ServiceContract(Namespace = "http:://company.url/area/concern/year/month/day")]
public interface IHWService {
    [OperationContract]
    string GetMessage();
}

public class HelloWorldService : IHWService{
    public string GetMessage(){
         return "Hello";
    }
}

//... in other assembly, for development self host console application
class Program{
    static void Main(string[] args){
       using(var host = new ServiceHost(typeof(HelloWorldService))){
         host.Open();
            Console.ReadLine();
        }
    }
}



为了实现这一目标,该主机的配置文件将指定类似
$的内容b $ b


To get that working, your config file of that host will specify something like

<system.serviceModel>
    <services>
        <service name="HWService" behviourConfiguration="yourservicebehaviour">
            <endpoint address="" contrac="IHWService" binding="basicHttpVinding" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:3000/" />
    // ...





现在新建代理并使用它就像
$ b一样简单$ b



Now newing up the proxy and using it is as simple as

using(var proxy = new HWService.WhatYouCalledYourReferenceClient()){
     Console.WriteLine(proxy.GetMessage());
}





因为你的那个地方的配置需要有它的版本system.servicemodel thingies abc(Address,Binding ,配置)镜像主机。



of cause your config of that place needs to have it's version of system.servicemodel thingies abc (Address, Binding, Configuration) to mirror the host.


这篇关于如何将请求发送到共享文件夹中的wsdl? (ASP.NET C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆