Thanks for your replay.
Sorry for the word "idle". In fact, I am a Chinese, who live in Beijing City, China. Shamed for the terrible english. If we talk a man wih free time, which word should we use? idle, free, leisure,or something else? :)
Okay, last two question: 1: I am a novice to soap, absolutely a newbie. Last week I began to develop Java Axis2 webservice and Python webservice. In python, the server-side use tornadows(tornado web service). They work together well, at least, I have never meet. "The "suds" documentation tells you how to specify the use of a specific port." In fact, I did not know how to specific port in suds. Some helps to me? :)
2: Have you once did something about Java axis2 client? I try to invoke a webservice develped by tornadows using axis2-client, but failed. I provided server-side, client-side and wsdl as follows. If leisure and pleasrue, hava a glance.
# server: import logging
import tornado.httpserver import tornado.ioloop import tornado.web from tornadows import soaphandler from tornadows import webservices from tornadows import xmltypes from tornadows.soaphandler import webservice from tornado.options import define, options
define('mode', default='deploy') define('port', type=int, default=8000) options['logging'].set('warning')
class SMSService(soaphandler.SoapHandler):
@webservice(_params=xmltypes.Integer,_returns=xmltypes.Integer) def getPrice(self,a): return 1987
if __name__ == '__main__': service = [('SMSService',SMSService)] app = webservices.WebService(service) ws = tornado.httpserver.HTTPServer(app)
ws.listen(options.port) logging.warn("SMSService running on: localhost:%d", options.port) tornado.ioloop.IOLoop.instance().start()
# client: package client;
import javax.xml.namespace.QName; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.rpc.client.RPCServiceClient;
public class client_for_python {
public static void main(String[] args) throws Exception {
// step 1: 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); // step 2: 指定调用WebService的URL // url for python String url2 = "http://172.16.2.46:8000/SMSService"; EndpointReference targetEPR = new EndpointReference(url2); options.setTo(targetEPR); // step 3: 指定getGreeting方法的参数值 // step 5-6: (similiar whit // it!)下面是调用getPrice方法的代码,这些代码与调用getGreeting方法的代码类似 Class[] classes = new Class[] { int.class }; QName opAddEntry = new QName( "http://172.16.2.46:8000/SMSService/getPrice"); System.out.println(serviceClient.invokeBlocking(opAddEntry, new Object[] {1}, classes)[0]); } }
## the prolem: no response and server-side get no data
#wsdl:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://127.0.1.1:8000/SMSService/getPrice" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="SMSService" targetNamespace="http://127.0.1.1:8000/SMSService/getPrice%22%3E wsdl:types <xsd:schema targetNamespace="http://127.0.1.1:8000/SMSService/getPrice%22%3E <xsd:complexType name="paramsTypes"> xsd:sequence <xsd:element name="a" type="xsd:integer"/> </xsd:sequence> </xsd:complexType> <xsd:element name="params" type="tns:paramsTypes"/> <xsd:element name="returns" type="xsd:integer"/> </xsd:schema> </wsdl:types> <wsdl:message name="SMSServiceRequest"> <wsdl:part element="tns:params" name="parameters"/> </wsdl:message> <wsdl:message name="SMSServiceResponse"> <wsdl:part element="tns:returns" name="parameters"/> </wsdl:message> <wsdl:portType name="SMSServicePortType"> <wsdl:operation name="getPrice"> <wsdl:input message="tns:SMSServiceRequest"/> <wsdl:output message="tns:SMSServiceResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SMSServiceBinding" type="tns:SMSServicePortType"> <soap:binding style="document" transport=" http://schemas.xmlsoap.org/soap/http%22/%3E <wsdl:operation name="getPrice"> <soap:operation soapAction="http://127.0.1.1:8000/SMSService" style="document"/> wsdl:input <soap:body use="literal"/> </wsdl:input> wsdl:output <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SMSService"> <wsdl:port binding="tns:SMSServiceBinding" name="SMSServicePort"> <soap:address location="http://127.0.1.1:8000/SMSService%22/%3E </wsdl:port> </wsdl:service> </wsdl:definitions>
Thanks !
-- Jia Xiaolei
On Wed, Dec 7, 2011 at 4:02 PM, Dieter Maurer dieter@handshake.de wrote:
贾晓磊 wrote at 2011-12-7 15:38 +0800:
... 1:By the url " http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" , we can get the words :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/%22xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://WebXml.com.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12=*" http://schemas.xmlsoap.org/wsdl/soap12/*%22xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://WebXml.com.cn/
">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/%22%3E
Maybe it's the fault of soap1.2
This tells us (only), that namespace prefixes are defined for both "SOAP" (1.1) as well as "SOAP1.2".
The WSDL may define two different ports, one destined for "SOAP" clients another one for "SOAP1.2" clients. In such a case, ensure that "suds" is using the port for "SOAP" clients.
The "suds" documentation tells you how to specify the use of a specific port.
In the cases, where I have seen different ports for "SOAP" and "SOAP1.2" in a WSDL, the port name has distinguished between the two protocols. I have not seen a more formal difference (but I may not have looked with sufficient intensity).
2: I once did a webservice server-side using suds. Most of time, they work together well. While, sometimes, suds returns some message like the exception mentioned above. If idle, wish you have a look and give me some points. Thanks in advance.
I am not idle ;-)
#NOTE: the code can also be found in " http://soaplib.github.com/soaplib/2_0/pages/helloworld.html" ... Sometimes, it returns exceptions as follows. most of time it return the result successfully after 2 or 3 minutes
Traceback (most recent call last): ... File "/usr/lib/python2.6/httplib.py", line 391, in begin version, status, reason = self._read_status() File "/usr/lib/python2.6/httplib.py", line 355, in _read_status raise BadStatusLine(line)
# okay, the problem is why sometimes the client return the exception and most of time return the correct results some minutes later?
When it works sometimes, this excludes a WSDL problem.
Nethertheless, the problem does not look client side -- but server side. You are getting a very low level exception: "httplib" (responsible for the elementary http request/response exchange) complaining about a bad status line (the first line of an HTTP response). The error information (the other part, aside from the traceback) should tell you which "line" has been received. You will find that it does not correspond to the HTTP specification.
To understand in details what happens between a client and a server, a TCP logger (e.g. "etherreal", "wireshark", ...) can be used. It protocols the communication between server and client and you can see precisely which side is responsible for bad behavior.
-- Dieter