Rpclib is a very useful Python WebService library, can dynamically generate WSDL, but this project has basically stopped, and was replaced by a new project Spyne, because the old project work has been relatively stable, so I did not rushed to upgrade to Spyne.
When I wrote the service method in Rpclib, I encountered a strange error: Accessing the WSDL (HTTP://LOCALHOST:9898/?WSDL) page and returning to the 502 bad Gateway.
You see the following error message in the log:
Copy the Code code as follows:
Valueerror:all strings must be XML compatible:unicode or ASCII, no NULL bytes or control characters
I checked the code, compared to the previous version of work, and found nothing wrong with it.
@srpc (Requestmodel, _returns=unicode) def Shenzhen (Request): "" " according to the incoming token, vehicle and Chei number, and the verification code to inquire about the vehicle's violation record "" " logging.info (Request) query = shenzhenquery (request) return Query.query_car_records ()
But instead of generating the WSDL correctly, I deleted all the contents of the method (including the comments), left only one statement that returned the Unicode string, and then worked fine, but when I joined the method's document comment and came out with the previous error, I doubted the comment: the comment in Chinese, But did not use Unicode string, so use U "" Chinese note "" ", Everything is OK!
View the generated WSDL and discover that the original rpclib was generated using annotations
Copy the Code code as follows:
Check the vehicle's violation according to incoming token, car and Chei number, and verification code.
Copy the Code code as follows:
No wonder the Chinese comments will go wrong!