使用WCF动态调用Web服务... [英] Dynamically Invoking Web Services... With WCF

查看:85
本文介绍了使用WCF动态调用Web服务...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用以下代码来调用wcf方法,而无需添加服务引用.有了这段代码,方法被调用了,但是我无法获取wcf方法中传递的参数值.请帮助我解决问题.

Hi,

I''m using the below code to call the wcf method without adding service reference. With this code the methods are getting called but I''m not able to get the passed parameter values in the wcf method. Please help me how to resolve the issue.

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
IChannelFactory<irequestchannel> factory = binding.BuildChannelFactory<irequestchannel>(new BindingParameterCollection());
factory.Open();

EndpointAddress address = 
    new EndpointAddress("http://localhost:2193/Service1.svc");
IRequestChannel irc = factory.CreateChannel(address);
using (irc as IDisposable)
{
    irc.Open();
    
    XmlReader reader = XmlReader.Create(new StringReader(
@"<getdatausingdatacontract xmlns="http://tempuri.org/">
<composite xmlns:a="http://schemas.datacontract.org/2004/07/">
xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<a:boolvalue>true</a:boolvalue>
<a:stringvalue>test values</a:stringvalue>
</composite>
</getdatausingdatacontract>"));
    Message m = Message.CreateMessage(MessageVersion.Soap11,
        "http://tempuri.org/IService/GetDataUsingDataContract", reader);
    
    Message ret = irc.Request(m);
    reader.Close();
    
    Console.WriteLine(ret);    
}

//close the factory
factory.Close();


提前谢谢.
问候
Seema


Thanks in advance.
Regards
Seema

推荐答案

hii,
希望对您有帮助

在没有合同界面的情况下从客户端调用WCF服务 [ ^ ]

http://www.c -sharpcorner.com/uploadfile/f9935e/invoking-a-web-service-dynamic-using-system-net-and-soap/ [
hii,
hope this will help you

Calling a WCF service from a client without having the contract interface[^]

http://www.c-sharpcorner.com/uploadfile/f9935e/invoking-a-web-service-dynamically-using-system-net-and-soap/[^]


这篇关于使用WCF动态调用Web服务...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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