1 Exhibit 5.1 February 7, 2000 webMethods, Inc. 3877 Fairfax Ridge Road Fourth Floor Fairfax, VA 22030 Re: Registration Statement on Form s-1 Ladies and Gentlemen: We have furnished this opinion to you in connection with a Registration Statement on Form S-1 (the "Registration Statement") to be filed with the Securities and Exchange Commission (the "Commission") under the Securities Act of 1933, as amended (the "Securities Act"), for the registration of an aggregate of 4,715,000 shares of Common Stock, $.01 par value per share (the "Shares"), of webMethods Corporation, a Delaware corporation (the "Company"), of which 615,000 shares are subject to the exercise of an over-allotment option granted by the Company to the Underwriters). The Shares are to be sold by the Company pursuant to an underwriting agreement (the "Underwriting Agreement") to be entered into by and among the Company and Morgan Stanley & Co. Incorporated, Merrill Lynch, Pierce, Fenner & Smith Incorporated, Dain Rauscher Incorporated and Friedman, Billings, Ramsey & Co., Inc., as representatives of the several underwriters named in such Underwriting Agreement, the form of which has been filed as Exhibit 1.1 to the Registration Statement. We are acting as counsel for the Company in connection with the sale by the Company of the Shares. We have examined signed copies of the Registration Statement as filed with the Commission. We have also examined and relied upon minutes of meetings of the stockholders and the Board of Directors of the Company as provided to us by the Company, stock record books of the Company as provided to us by the Company, the Fourth Amended and Restated Certificate of Incorporation and Bylaws of the Company, each as amended and/or restated to date, and such other documents as we have deemed necessary for purposes of rendering the opinions hereinafter set forth. In our examination of the foregoing documents, we have assumed the genuineness of all signatures, the authenticity of all documents submitted to us as originals, the conformity to original documents of all documents submitted to us as certified photostatic or facsimile 2 February 7, 2000 Page 2 copies and the authenticity of the original of such latter documents, and legal capacity of all natural persons. We assume that the appropriate action will be taken, prior to the offer and sale of the Shares in accordance with the Underwriting Agreement, to register and qualify the Shares for sale under all applicable state securities or "blue sky" laws. We express no opinion herein as to the laws of any state or jurisdiction other than the Delaware General Corporation Law Statute, reported judicial decisions interpreting such statute and applicable provisions of the Constitution of the State of Delaware, and the federal laws of the United States of America. To the extent that any other laws govern the matters as to which we are opining herein, we have assumed that such laws are identical to the state laws of the State of Delaware, and we are expressing no opinion herein as to whether such assumption is reasonable or correct. Based upon and subject to the foregoing, we are of the opinion that the Shares have been duly authorized for issuance and the Shares, when issued and paid for in accordance with the terms of the Plans, will be validly issued, fully paid and nonassessable. It is understood that this opinion is to be used only solely in connection with the offer and sale of Shares while the Registration Statement is in effect. Please note that we are opining only as to the matters expressly set forth in this letter, and no other opinion should be inferred beyond the matters expressly stated herein. We hereby consent to the filing of this opinion with the Commission as an exhibit to the Registration Statement in accordance with the requirements of Item 601(b)(5) of Regulation S-K under the Securities Act. In giving such consent, we do not admit that we are in the category of persons whose consent is required under Section 7 of the Securities Act or rules and regulations of the Commission. Very truly yours, /s/ Shaw Pittman Shaw Pittman A Partnership Including Professional Corporations