WEB Service新手學習遇到的困難 ( 积分: 200 )

  • 主题发起人 主题发起人 天空还下着沙
  • 开始时间 开始时间

天空还下着沙

Unregistered / Unconfirmed
GUEST, unregistred user!
一年多前有了解一下WEB SERVICE,當時選了COM+的HTTP方式連接,現在想試著改成WEB SERVICE,所以翻出舊書學習,但第一個DEMO就遇阻,比較打擊信心
服務端已完成,從IIS上可以顯示和訪問我的DLL,並可有輸出WSDL
<?xml version=&quot;1.0&quot;
encoding=&quot;utf-8&quot;?>
<definitions xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
name=&quot;ISayHelloservice&quot;
targetNamespace=&quot;http://tempuri.org/&quot;
xmlns:tns=&quot;http://tempuri.org/&quot;
xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
xmlns:soapenc=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:mime=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot;>
<message name=&quot;SayWithName0Request&quot;>
<part name=&quot;sName&quot;
type=&quot;xs:string&quot;/>
</message>
<message name=&quot;SayWithName0Response&quot;>
<part name=&quot;return&quot;
type=&quot;xs:string&quot;/>
</message>
<portType name=&quot;ISayHello&quot;>
<operation name=&quot;SayWithName&quot;>
<input message=&quot;tns:SayWithName0Request&quot;/>
<output message=&quot;tns:SayWithName0Response&quot;/>
</operation>
</portType>
<binding name=&quot;ISayHellobinding&quot;
type=&quot;tns:ISayHello&quot;>
<soap:binding style=&quot;rpc&quot;
transport=&quot;http://schemas.xmlsoap.org/soap/http&quot;/>
<operation name=&quot;SayWithName&quot;>
<soap:operation soapAction=&quot;urn:SayHelloIntf-ISayHello#SayWithName&quot;
style=&quot;rpc&quot;/>
<input message=&quot;tns:SayWithName0Request&quot;>
<soap:body use=&quot;encoded&quot;
encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
namespace=&quot;urn:SayHelloIntf-ISayHello&quot;/>
</input>
<output message=&quot;tns:SayWithName0Response&quot;>
<soap:body use=&quot;encoded&quot;
encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
namespace=&quot;urn:SayHelloIntf-ISayHello&quot;/>
</output>
</operation>
</binding>
<service name=&quot;ISayHelloservice&quot;>
<port name=&quot;ISayHelloPort&quot;
binding=&quot;tns:ISayHellobinding&quot;>
<soap:address location=&quot;http://localhost/Scripts/Project1.dll/soap/ISayHello&quot;/>
</port>
</service>
</definitions>

客戶端兩種方式都出錯,接口不支持。
uses SayHelloIntf;
procedure TForm1.Button1Click(Sender: TObject);
begin
HTTPRIO1.WSDLLocation := 'http://localhost/Scripts/Project1.dll/wsdl/ISayHello';
Edit1.Text := (HTTPRIO1 as ISayHello).SayWithName('Yuan');
//李維老師的書上是用的這種
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
SoapConnection1.URL := 'http://localhost/Scripts/Project1.dll/wsdl/ISayHello';
Edit1.Text := SoapConnection1.AppServer.SayWithName('Yuan');
end;

謝謝各位前輩/過來人的舉手之勞。
 
一年多前有了解一下WEB SERVICE,當時選了COM+的HTTP方式連接,現在想試著改成WEB SERVICE,所以翻出舊書學習,但第一個DEMO就遇阻,比較打擊信心
服務端已完成,從IIS上可以顯示和訪問我的DLL,並可有輸出WSDL
<?xml version=&quot;1.0&quot;
encoding=&quot;utf-8&quot;?>
<definitions xmlns=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
name=&quot;ISayHelloservice&quot;
targetNamespace=&quot;http://tempuri.org/&quot;
xmlns:tns=&quot;http://tempuri.org/&quot;
xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;
xmlns:soapenc=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:mime=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot;>
<message name=&quot;SayWithName0Request&quot;>
<part name=&quot;sName&quot;
type=&quot;xs:string&quot;/>
</message>
<message name=&quot;SayWithName0Response&quot;>
<part name=&quot;return&quot;
type=&quot;xs:string&quot;/>
</message>
<portType name=&quot;ISayHello&quot;>
<operation name=&quot;SayWithName&quot;>
<input message=&quot;tns:SayWithName0Request&quot;/>
<output message=&quot;tns:SayWithName0Response&quot;/>
</operation>
</portType>
<binding name=&quot;ISayHellobinding&quot;
type=&quot;tns:ISayHello&quot;>
<soap:binding style=&quot;rpc&quot;
transport=&quot;http://schemas.xmlsoap.org/soap/http&quot;/>
<operation name=&quot;SayWithName&quot;>
<soap:operation soapAction=&quot;urn:SayHelloIntf-ISayHello#SayWithName&quot;
style=&quot;rpc&quot;/>
<input message=&quot;tns:SayWithName0Request&quot;>
<soap:body use=&quot;encoded&quot;
encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
namespace=&quot;urn:SayHelloIntf-ISayHello&quot;/>
</input>
<output message=&quot;tns:SayWithName0Response&quot;>
<soap:body use=&quot;encoded&quot;
encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
namespace=&quot;urn:SayHelloIntf-ISayHello&quot;/>
</output>
</operation>
</binding>
<service name=&quot;ISayHelloservice&quot;>
<port name=&quot;ISayHelloPort&quot;
binding=&quot;tns:ISayHellobinding&quot;>
<soap:address location=&quot;http://localhost/Scripts/Project1.dll/soap/ISayHello&quot;/>
</port>
</service>
</definitions>

客戶端兩種方式都出錯,接口不支持。
uses SayHelloIntf;
procedure TForm1.Button1Click(Sender: TObject);
begin
HTTPRIO1.WSDLLocation := 'http://localhost/Scripts/Project1.dll/wsdl/ISayHello';
Edit1.Text := (HTTPRIO1 as ISayHello).SayWithName('Yuan');
//李維老師的書上是用的這種
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
SoapConnection1.URL := 'http://localhost/Scripts/Project1.dll/wsdl/ISayHello';
Edit1.Text := SoapConnection1.AppServer.SayWithName('Yuan');
end;

謝謝各位前輩/過來人的舉手之勞。
 
就是在李維老師的D6/K2 SOAP/Web Service程序設計
第3章,第60頁
程序能編輯通過,但不能運行
 
在D7的DEMO目錄裡,還找到一種方法,但仍然報接口不支持的錯誤
(SoapConnection2.GetSOAPServer as ISayHello).SayWithName('Yuanjun');
 
没看清,不过D6做的webservice服务器有BUG,最好不要用
 
[:)] 我用的是D7, Win2000IIS
还有没有大哥帮帮我啊
WSDL有了。连接也连上了,就是不能调用。SoapConnection2, HTTPRIO1两种都不行啊
 
Received content of invalid Content-Type setting: text/html - SOAP excepts &quot;text/xml&quot;
出了新狀況,這個錯誤跑出來了。還有HTTPRIO1的WSDLLocation屬性不同時出了個小錯
http://localhost/Scripts/Project2.dll/wsdl/IWM2 正常
http://localhost/Scripts/Project2.dll/soap/IWM2 再選service屬性就不正常,報錯接口不支持
wsdl/soap的區別

要暈了,有沒有前輩指點一下啊。晚上睡覺前看能不能解決了
 
... 有些失望,很久沒來大富翁了,還是這樣,提的問題不能解決,也許是我問題提的不好。
打開D7的DEMO後發現了,原來是接口函數要定義成stdcall。
 
接受答案了.
 

Similar threads

后退
顶部