Class: JasperClient::RepositoryService::Request
- Inherits:
-
Object
- Object
- JasperClient::RepositoryService::Request
- Defined in:
- lib/jasper-client/jasper_client.rb
Overview
Request XML is built using the Request.
A request looks like:
<?xml version=“1.0” encoding=“utf-8”?> <soapenv:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:axis="http://axis2.ws.jasperserver.jaspersoft.com">
<soapenv:Body>
<axis:list soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<requestXmlString xsi:type="xsd:string">
<![CDATA[
<request operationName="list">
<argument name="LIST_RESOURCES"/>
<argument name="RESOURCE_TYPE">reportUnit</argument>
<argument name="START_FROM_DIRECTORY">/Reports/xforty</argument>
</request>
]]>
</requestXmlString>
</axis:list>
</soapenv:Body>
</soapenv:Envelope>
The soap envelope, body, and action (in this case axis:list) elements are automatically constructed by Savon. The requestXmlString element and sub elements are created by the build() method. This method yields a builder that is expected to create the contents of the request element (the arugment tags in this case).
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#build(&block) ⇒ Object
Takes a block which is yielded with an XML builder that represents the internal XML inside the <request> tags in the request.
-
#initialize(name) ⇒ Request
constructor
Create a new Request.
-
#soap_method ⇒ Object
Returns the soap method name for this request.
Constructor Details
#initialize(name) ⇒ Request
Create a new Request. The name passed is the request name (eg list, get, runReport).
91 92 93 |
# File 'lib/jasper-client/jasper_client.rb', line 91 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
87 88 89 |
# File 'lib/jasper-client/jasper_client.rb', line 87 def name @name end |
Instance Method Details
#build(&block) ⇒ Object
Takes a block which is yielded with an XML builder that represents the internal XML inside the <request> tags in the request.
98 99 100 101 102 103 104 105 106 |
# File 'lib/jasper-client/jasper_client.rb', line 98 def build(&block) inner_xml = Builder::XmlMarkup.new :indent => 2 inner_xml.request 'operationName' => soap_method do |request| yield request end body = Builder::XmlMarkup.new :indent => 2 body.requestXmlString { |request_string| request_string.cdata! inner_xml.target! } end |
#soap_method ⇒ Object
Returns the soap method name for this request.
109 110 111 |
# File 'lib/jasper-client/jasper_client.rb', line 109 def soap_method self.name.to_s.underscore end |