Annotation issues when using Rpclib for Python network programming

Source: Internet
Author: User
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!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.