大家好,
我用delphi写了一个webservice,用delphi作为客户端调用测试已经没问题。现在需要用extjs调用webservice里的函数,我该如何做?
1. 用其它语言调用webservice时,都要用wsdl地址(如:
http://localhost:8080/wsdl/IMyWebService)保存一个webservice的所有函数的定义等的文件,用extjs是否也需要?如果需要如何做?
2. 我在网上查到有如下类似代码:
Ext.onReady(function(){
Ext.Ajax.request({
url:'http://192.168.1.102/ExtJS/Webservice/TestWebservice/TestWebService/Service1.asmx/HelloWorld', //Webservice发布地址
method:'POST',
headers:{'Content-Type':'application/json;utf-8'},//在这里一定要指定头信息为json,否则将返回的是XML,而不是Json
success:function(response,options){
Ext.Msg.alert('成功',response.responseText);
},
failure:function(){
Ext.Msg.alert('失败','与Webservice连接失败');
}
});
});
当然,我的与它不一样,但原理是一样的,我试了一下,不行,操作时服务器端调用的函数根本就没有进入,说明方法不对。
请大家帮忙看一下,有什么方法?
先谢谢大家!!!!!!!
附:
http://localhost:8080/wsdl/IMyWebService的内容如下:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" 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/" name="IZCWebServiceservice" targetNamespace="http://tempuri.org/">
<message name="echoTest0Request">
<part name="ms_true" type="xs:string"/>
</message>
<message name="echoTest0Response">
<part name="return" type="xs:string"/>
</message>
<message name="login1Request">
<part name="ms_option" type="xs:string"/>
</message>
<message name="login1Response">
<part name="return" type="xs:string"/>
</message>
<message name="logout2Request">
<part name="ms_option" type="xs:string"/>
</message>
<message name="logout2Response">
<part name="return" type="xs:string"/>
</message>
<message name="querySQL3Request">
<part name="ms_option" type="xs:string"/>
</message>
<message name="querySQL3Response">
<part name="return" type="xs:string"/>
</message>
<message name="execSQL4Request">
<part name="ms_option" type="xs:string"/>
</message>
<message name="execSQL4Response">
<part name="return" type="xs:string"/>
</message>
<message name="getFileList5Request">
<part name="ms_rand" type="xs:string"/>
</message>
<message name="getFileList5Response">
<part name="return" type="xs:string"/>
</message>
<message name="getFile6Request">
<part name="ms_rand" type="xs:string"/>
<part name="ms_fileName" type="xs:string"/>
</message>
<message name="getFile6Response">
<part name="return" type="xs:base64Binary"/>
</message>
<portType name="IMyWebService">
<operation name="echoTest">
<input message="tns:echoTest0Request"/>
<output message="tns:echoTest0Response"/>
</operation>
<operation name="login">
<input message="tns:login1Request"/>
<output message="tns:login1Response"/>
</operation>
<operation name="logout">
<input message="tns:logout2Request"/>
<output message="tns:logout2Response"/>
</operation>
<operation name="querySQL">
<input message="tns:querySQL3Request"/>
<output message="tns:querySQL3Response"/>
</operation>
<operation name="execSQL">
<input message="tns:execSQL4Request"/>
<output message="tns:execSQL4Response"/>
</operation>
<operation name="getFileList">
<input message="tns:getFileList5Request"/>
<output message="tns:getFileList5Response"/>
</operation>
<operation name="getFile">
<input message="tns:getFile6Request"/>
<output message="tns:getFile6Response"/>
</operation>
</portType>
<binding name="IMyWebServicebinding" type="tns:IMyWebService">
<binding xmlns="http://schemas.xmlsoap.org/wsdl/soap/" style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="echoTest">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#echoTest" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="login">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#login" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="logout">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#logout" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="querySQL">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#querySQL" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="execSQL">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#execSQL" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="getFileList">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#getFileList" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</output>
</operation>
<operation name="getFile">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:MyWebServiceIntf-IMyWebService#getFile" style="rpc"/>
<input>
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</input>
<output>
<mime:multipartRelated>
<part xmlns="http://schemas.xmlsoap.org/wsdl/mime/">
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:MyWebServiceIntf-IMyWebService"/>
</part>
<part xmlns="http://schemas.xmlsoap.org/wsdl/mime/">
<content part="return" type="application/binary"/>
</part>
</mime:multipartRelated>
</output>
</operation>
</binding>
<service name="IMyWebServiceservice">
<port name="IMyWebServicePort" binding="tns:IMyWebServicebinding">
<address xmlns="http://schemas.xmlsoap.org/wsdl/soap/" location="http://localhost:8080/soap/IMyWebService"/>
</port>
</service>
</definitions>
我用extjs调用webservice中的函数时,是否需要把上面的内容保存成一个什么文件?
--
修改:darlingpeng FROM 59.49.77.*
FROM 59.49.77.*