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