delphi调用C# WebService 出错?

whynozg2007 2007-02-03 09:32:52
C# WebService中的函数
[WebMethod]
public string Test_Pro(string vString)
{
return vString;
}

Delphi中调用为:
var
d:ServiceSoap;
begin
d:=GetServiceSoap();
Caption:= d.Test_Pro('asdasdasdasd');

但是调用出错,但是VS调试又是正确的,不晓得怎么办?
...全文
605 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
红枫叶随风 2010-11-29
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 lexchou 的回复:]

InvRegistry.RegisterInvokeOptions(TypeInfo(XXXXXXSoap),ioDocument);
在生成的Service.pas的initialization里面加上这么一句话
[/Quote]

同意这个说法
songfuqiang 2007-12-13
  • 打赏
  • 举报
回复
你可以在IE中输入地址看行不?如果都行了哪就让delphi行动形成接口.调用方法:
HTTPRIO1:=THTTPRIO.Create(Application);
Area:=nil;
HTTPRIO1.WSDLLocation:='http://locahost:8080/services/MandiQ?wsdl';//java写的Web Services的访问方法
try
(HTTPRIO1 as MandiQPortType).getAllTradeBig;
except
Application.MessageBox('连接Web Service失败!','提示',MB_ICONERROR );
end;
weixin_1374426001 2007-11-22
  • 打赏
  • 举报
回复
直接用自动生成接口里的方法,看明白每步是做什么的再写
helodd 2007-11-16
  • 打赏
  • 举报
回复
C# 的webservices 要想有delphi 调通,服务端要加上 [SoapRpcService(RoutingStyle=SoapServiceRoutingStyle.SoapAction)]

这个参数吧
geoffe 2007-11-12
  • 打赏
  • 举报
回复
我也遇到类似的错误,unable to retrive the url endpiont......
用的是 “hongqi162”的一样方法
jxauyhj 2007-03-07
  • 打赏
  • 举报
回复
var
ITelWebServiceSoap :TelWebServiceSoap;
RoutesObj : ArrayOfRoute;
error : ErrorInfo;
begin
ITelWebServiceSoap :=(HTTPRIO1 as TelWebServiceSoap);//这样转一下
error:=ITelWebServiceSoap.CheckUser('aa','aa');
Memo1.Lines.Clear;
if error.m_bERROR=false then
begin
Memo1.Lines.Add(错误信息!'+error.m_ERROR_INFO);
exit;
end;
ITelWebServiceSoap.GetRouteListByCode('aa',2,Surveyid.Text,error,RoutesObj);
if error.m_bERROR=false then //---³ö´í ûÓлñÈ¡µ½Êý¾Ý
begin
Memo1.Lines.Add(取得数据:'+error.m_ERROR_INFO);
end
else
begin
Memo1.Lines.Add(IntToStr(Length(RoutesObj)));
end;
ITelWebServiceSoap.Exit;
end;
loskill 2007-03-06
  • 打赏
  • 举报
回复
搞毛啊,出了什么错也不说。
lexchou 2007-03-02
  • 打赏
  • 举报
回复
InvRegistry.RegisterInvokeOptions(TypeInfo(XXXXXXSoap),ioDocument);
在生成的Service.pas的initialization里面加上这么一句话
IT动力 2007-03-02
  • 打赏
  • 举报
回复
报什么错也不写,叫人如何帮你?
hongqi162 2007-02-28
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,SoapHTTPClient,InvokeRegistry, Types, XSBuiltIns;
type
ExampleSoap = interface(IInvokable)
['{444725B4-3750-586C-5497-8EE30CDE10B9}']
function HelloWorld: WideString; stdcall;
function getStr(const s: WideString): WideString; stdcall;
end;

TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation


{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
X :THTTPRio;
InterfaceVariable: ExampleSoap;
begin
X :=THTTPRio.Create(nil);
x.HTTPWebNode.UseUTF8InHeader:=true;
x.WSDLLocation:='http://localhost/MyWebService/Example.asmx?wsdl';
InterfaceVariable := X as ExampleSoap;
showmessage(InterfaceVariable.HelloWorld);
showmessage(InterfaceVariable.getStr('hello world'));
x.Free;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(ExampleSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ExampleSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ExampleSoap), ioDocument);
end.
hongqi162 2007-02-28
  • 打赏
  • 举报
回复
file-new-other-webservice-wsdl importer

http://localhost/MyWebService/Example.asmx?wsdl


// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/MyWebService/Example.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2007-2-28 12:19:12 - 1.33.2.5)
// ************************************************************************ //

unit Example;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"



// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : ExampleSoap
// service : Example
// port : ExampleSoap
// URL : http://localhost/MyWebService/Example.asmx
// ************************************************************************ //
ExampleSoap = interface(IInvokable)
['{444725B4-3750-586C-5497-8EE30CDE10B9}']
function HelloWorld: WideString; stdcall;
function getStr(const s: WideString): WideString; stdcall;
end;

function GetExampleSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ExampleSoap;


implementation

function GetExampleSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ExampleSoap;
const
defWSDL = 'http://localhost/MyWebService/Example.asmx?wsdl';
defURL = 'http://localhost/MyWebService/Example.asmx';
defSvc = 'Example';
defPrt = 'ExampleSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as ExampleSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(ExampleSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ExampleSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ExampleSoap), ioDocument);

end.
foison 2007-02-27
  • 打赏
  • 举报
回复
我也遇到了类似问题.
lextm 2007-02-05
  • 打赏
  • 举报
回复
没记错的话需要用HttpRIO,不知道你怎么用ServiceSoap。
cangwu_lee 2007-02-03
  • 打赏
  • 举报
回复
说说调用的具体,这样看不出什么问题来。


Bear_hx 2007-02-03
  • 打赏
  • 举报
回复
帮你提前

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧