Scan SOA and output all service methods

Source: Internet
Author: User
Tags xpath

Today, most companies adopt an SOA architecture. So how do we know what service methods SOA provides? is the browser constantly clicking on the attempt? or through WCF? Or is there always a document behind the code in the software development industry by reading the SOA interface documentation? These tactics are too clumsy. In fact, we can achieve this goal through some quicker and more efficient means.

The background to this idea is that our company deploys several SOA services. Then we test automation is very dispersed, form a variety of various, is simply eight Immortals crossing recount, very difficult to statistical automation coverage statistics. As a results, the method of using script to scan statistics is thought. Not muchSaidout,Directly on the code,The script is as follows:
#Coding=utf-8ImportRequests fromlxmlImportetree fromSuds.clientImportClientImportCsvpresoa= R"http://192.168.1.20:8085/"Soaurl=requests.get (Presoa) detail_html=etree. HTML (soaurl.content) links=detail_html.xpath (Ur"//a") HREFs= [Presoa +x.attrib["href"] forXinchLinksif ". config"  not inchX.text and "bin"  not inchX.text and "Demo"  not inchX.text and ". asax"  not inchX.text]svclinks=[]defGetsvcurl (templink): Tempsoaurlcontent=Requests.get (templink). Content temphtml=etree. HTML (tempsoaurlcontent) Temphtmllink=temphtml.xpath (Ur"//a/text ()") Svclink= [Templink + x +"? singlewsdl"  forXinchTemphtmllinkif ". svc" inchx] [Svclinks.append (x) forXinchSvclink] [Getsvcurl (x) forXinchHrefs]getsvcurl (Presoa)Print "Svc count:{0}". Format (len (svclinks)) client=Client (svclinks[0]) svcfuns=[]defDealsvcmethods (Svclink): Methods=[X[0] forXinchClient (svclink). sd[0].ports[0][1]] [Svcfuns.append ({"funcname": X,"Svc": Svclink}) forXinchmethods] [Dealsvcmethods (x) forXinchsvclinks]with open (Ur"E:\ main station Soa2016-10-25.csv",'ab+') as Csvfile:writer= csv. Dictwriter (csvfile,fieldnames = ["funcname","Svc"]) Writer.writeheader () writer.writerows (svcfuns)

Of course, there are prerequisites for using this approach. First, the SOA site must expose the service. With this, we can easily find out the new service methods before and after the version.

Scan SOA and output all service methods

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.