winfrom调用接口 急

.Net技术 码拜 8年前 (2016-03-08) 1124次浏览
本人现在有这么一个接口
//–
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.36315
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//–
namespace PrintClient.PrintSrvRef {

[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”, “4.0.0.0”)]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName=”PrintSrvRef.IPrintTask”)]
public interface IPrintTask {

[System.ServiceModel.OperationContractAttribute(Action=”http://tempuri.org/IPrintTask/GetTemplates”, ReplyAction=”http://tempuri.org/IPrintTask/GetTemplatesResponse”)]
PrintControl.Model.tb_FoldedHandTemplate[] GetTemplates();

[System.ServiceModel.OperationContractAttribute(Action=”http://tempuri.org/IPrintTask/GetPrints”, ReplyAction=”http://tempuri.org/IPrintTask/GetPrintsResponse”)]
PrintControl.Model.PrintTemplate[] GetPrints();

[System.ServiceModel.OperationContractAttribute(Action=”http://tempuri.org/IPrintTask/SubmitFile”, ReplyAction=”http://tempuri.org/IPrintTask/SubmitFileResponse”)]
int SubmitFile(string filename, PrintControl.Model.PrintTemplate ptTpl, PrintControl.Model.tb_FoldedHandTemplate fhTpl, int cpy);
}

[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”, “4.0.0.0”)]
public interface IPrintTaskChannel : PrintClient.PrintSrvRef.IPrintTask, System.ServiceModel.IClientChannel {
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.ServiceModel”, “4.0.0.0”)]
public partial class PrintTaskClient : System.ServiceModel.ClientBase<PrintClient.PrintSrvRef.IPrintTask>, PrintClient.PrintSrvRef.IPrintTask {

public PrintTaskClient() {
}

public PrintTaskClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}

public PrintTaskClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public PrintTaskClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public PrintTaskClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}

public PrintControl.Model.tb_FoldedHandTemplate[] GetTemplates() {
return base.Channel.GetTemplates();
}

public PrintControl.Model.PrintTemplate[] GetPrints() {
return base.Channel.GetPrints();
}

public int SubmitFile(string filename, PrintControl.Model.PrintTemplate ptTpl, PrintControl.Model.tb_FoldedHandTemplate fhTpl, int cpy) {
return base.Channel.SubmitFile(filename, ptTpl, fhTpl, cpy);
}
}
}
本人定义了实现类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PrintClient.PrintSrvRef;
namespace PrintClient
{
class ImplementationClass : IPrintTask
{
public ImplementationClass()
{ }

}
}
本人没接触过这个   啥也不懂  求高手指点实现类里应该怎么写

解决方案

20

IPrintTask 这是WCF操作契约
PrintTaskClient : System.ServiceModel.ClientBase
你这个是个WCF的代理类,所以你只要配置正确,那直接new了用就可以了,确认你的服务是WCF服务,假如是WebService服务,最好还是用wsdl的方式生成代理类,原因是ws的soap协议和wcf的httpbinding协议有些差异,有些WS服务通过WCF方式添加引用后,实际使用会有问题

10

WebService服务,首先要弄清楚这些调用使用!

20

wsdl生成代理类
wsdl.exe /l:cs /out:D:/Service1.cs 你的asmx路径

10

按照接口说明来写,很简单的

10

扫描了一下程序,好像就是一个调用webservice的程序,你得首先知道调用协议才行,不然你蒙到整,整不好的

30

引用 8 楼 woshihaorenyajun 的回复:
Quote: 引用 4 楼 lovelj2012 的回复:

wsdl生成代理类
wsdl.exe /l:cs /out:D:/Service1.cs 你的asmx路径

刚才发现项目里石油wsdl文件的   那接下来该怎样调用接口

把生成的代理类,添加到项目中直接用


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明winfrom调用接口 急
喜欢 (0)
[1034331897@qq.com]
分享 (0)