您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> delphi调用C#的Webservice出现的问题,请教高手。急。

delphi调用C#的Webservice出现的问题,请教高手。急。

来源:网络整理     时间:2016/5/16 14:58:12     关键词:webservice

关于网友提出的“delphi调用C#的Webservice出现的问题,请教高手。急。”问题疑问,本网通过在网上对“delphi调用C#的Webservice出现的问题,请教高手。急。”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:delphi调用C#的Webservice出现的问题,请教高手。急。
描述:

公司原来有delphi的系统调用delphi的webservice,现在由于某种原因,需要调用C#的webservice,可是我把webservice写好,却调用不成功。后来google了一下,上面有人说这个原因:

因为VS.Net 2005 默认是用的SoapDocumentProtocol,而Delphi 是使用的 SoapRpcProtocol,这会造成客户端传过去的字符串都变为Null。在delphi程序中Authenticate单元的初始化initialization加入InvRegistry.RegisterInvokeOptions(TypeInfo(AuthenticateSoap), ioDocument);可以解决该问题。

然后我肯定不能动原来delphi的程序,请问在C#中怎么改可以解决?


解决方案1:

C#程序不需要修改,好像是Delphi加多一个引用

解决方案2:

下面这篇文章讲了如何让 .net 的 web service 同时支持 RPC 和 Document SOAP,

你参考一下吧。

http://radio.weblogs.com/0105476/stories/2002/04/12/rpcAndDocumentSoapFromOnenetWebService.html

下面这个是中文的

http://msdn.microsoft.com/zh-cn/library/system.web.services.protocols.soaprpcmethodattribute(VS.80).aspx

<%@ WebService Language="C#"class="MyUser" %>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
publicclass MyUser : WebService {
[ SoapRpcMethod(Action="http://www.contoso.com/Sample",
RequestNamespace="http://www.contoso.com/Request",
RequestElementName="GetUserNameRequest",
Resp>"http://www.contoso.com/Response",
Resp>"GetUserNameResponse")]
[ WebMethod(Description="Obtains the User Name") ]
public UserName GetUserName() {
string temp;
int pos;
UserName NewUser = new UserName();
// Get the full user name, including the domain name if applicable.
temp = User.Identity.Name;
// Determine whether the user is part of a domain by searching for a backslash.
pos = temp.IndexOf("\\");
// Parse out the domain name from the string, if one exists.
if (pos <= 0)
NewUser.Name = User.Identity.Name;
else {
NewUser.Name = temp.Remove(0,pos+1);
NewUser.Domain = temp.Remove(pos,temp.Length-pos);
}
return NewUser;
}
}
publicclass UserName {
publicstring Name;
publicstring Domain;
}

以上介绍了“delphi调用C#的Webservice出现的问题,请教高手。急。”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1110026.html

相关图片

相关文章