背景:最近想要在C#项目里使用python的第三方库(numpy、scipy),直接引用的时候出现各种错误,听别人的建议就转用http调用的方法。
问题:但是我在采用与C#发布的服务相同的方法去调用spyne发布的服务的时候就各种报错。
希望各位大神能结合spyne的helloworld服务的例子给我讲一下引用的过程,非常感谢。
/*--------------------------引用界面及报错内容如下-------------------------------*/
这是添加服务引用的界面:
这是我引用的代码的片段:
实例化:HelloTest.ApplicationClient HW=new HelloTest.ApplicationClient();
引用:string[] RecMSG=HW.say_hello("World",3);
报错:"say_hello"方法没有采用两个参数的重载
相关问题
- How to describe element attributes with Spyne
- Spyne receiving multiple requests
- Spyne - how to duplicate one elements of wsdl file
- WebService 外网端口映射访问 端口丢失问题
- php写的webservice但没有wsdl如何让java调用
相关文章
- WebService 外网端口映射访问 端口丢失问题
- php写的webservice但没有wsdl如何让java调用
- WebService“从服务器请求”到“服务器开始响应”要耗时5秒左右,怎么解决?
- wsdl中的Response返回两个值
- SoapUI接口测试成功,IIS发布后,接口却无法访问
- python spyne service - base64 strings come escaped
- 合格元素/属性的形式和与Spyne肥皂服务器不合格形式(Qualified element/attr
- Restrict spyne SOAP service with oauth2_provider
已经解决了,谢谢各位。
以图片中Sum为例,
看下vs生成的say_hello的函数签名
以前的silverlight实现soap请求,你完全可以自己调用一次,然后http模拟出来就行了。
文中异常明显是出错在调用对方接口 —— 参数不对。
public abstract class QueryBase : UserControl, IReflactor { public const string SpaceName = "VMS.Views.MainPageItems.QueryItems.BussinessQuerys."; public static readonly Assembly CurrentAssembly = Assembly.GetExecutingAssembly(); public static readonly string CurrentAssemblyName = CurrentAssembly.FullName;
protected QueryBase() { ParamsQuery = new List<IParamQuery>(); LoadingForm = new LoadingWindow(); SetFunParamValues(CreateQueryParams()); DownloadSucesss += OnDownloadData; }
public string Data { get; private set; }
/// <summary> /// 除去Host的相对Uri /// </summary> public abstract string Uri { get; }
public abstract string Fun { get; } public List<IParamQuery> ParamsQuery { get; private set; } public LoadingWindow LoadingForm { get; private set; }
public virtual string Caption { get { return GetType().Name; } }
public virtual string FullName { get { return GetType().FullName; } }
public event Action<string> DownloadSucesss; public virtual event Action<Exception> OnError;
private void SetFunParamValues(IList<IParamQuery> paramsControls) { if (paramsControls == null) return; //throw new FormatException("查询参数不能为NULL"); ParamsQuery.AddRange(paramsControls); }
protected abstract IList<IParamQuery> CreateQueryParams();
private string CreateBody() { var contentBody = new StringBuilder(); contentBody.Append("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"); contentBody.Append( "<s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
contentBody.AppendFormat("<{0}xmlns=\"http://tempuri.org/\">", Fun); foreach (IParamQuery funParam in ParamsQuery) contentBody.AppendFormat("<{0}>{1}</{0}>", funParam.PName, funParam.PValue); contentBody.AppendFormat("</{0}>", Fun);
contentBody.Append("</s:Body>"); contentBody.Append("</s:Envelope>"); return contentBody.ToString(); }
protected abstract Exception Validate();
protected virtual bool ValidateDealling(Exception ex) { if (ex == null) { return true; } if (OnError != null) OnError.Invoke(ex); return false; }
public virtual void LoadData() { if (LoadingForm.IsDownloading) return; if (!ValidateDealling(Validate())) return; LoadingForm.Show(); var webClient = new WebClient(); webClient.UploadStringCompleted += (sender, args) => { if (!LoadingForm.IsDownloading) return; if (args.Error != null) { if (OnError != null) OnError.Invoke(new NetWorkException("网络错误", args.Error)); } else if (args.Result == null) { if (OnError != null) OnError.Invoke(new NetWorkException("数据错误", args.Error)); } else { try { XDocument doc = XDocument.Parse(args.Result); Data = doc.Root.Value; if (DownloadSucesss != null) DownloadSucesss.Invoke(Data); } catch (Exception ex) { OnError.Invoke(new NetWorkException("数据读取错误", ex)); } } LoadingForm.Close(); }; webClient.Headers["SOAPAction"] = string.Format("http://tempuri.org/{0}", Fun); webClient.Headers["Content-Type"] = "text/xml; charset=utf-8"; string soapBody = CreateBody(); webClient.UploadStringAsync( new Uri(string.Format("http://{0}:8001/{1}", WebServiceHelper.Host, Uri), UriKind.Absolute), soapBody); }
protected abstract void OnDownloadData(string content); }