Method: BPEL_Transform#transform_invocation

Defined in:
lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb

#transform_invocationObject

}}}



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cpee/processtransformation/bpel/lib/BPEL_Transform.rb', line 88

def transform_invocation # {{{
  result = XML::Smart.string('<invocations/>')
  @doc.find("/bpel:process/bpel:sequence/bpel:receive[@createInstance='yes']").each do |e|
    op = e.attributes['operation']
    plnk_name = e.attributes['partnerLink']
    @doc.find("/bpel:process/bpel:partnerLinks/bpel:partnerLink[@name=\"#{plnk_name}\"]").each do |f|
      plnk_role = f.attributes['myRole'] 
      plnk_type = remove_ns f.attributes['partnerLinkType']
      @doc.find("/bpel:process/bpel:import[@importType=\"http://www.w3.org/ns/wsdl\"]").each do |g|
        XML::Smart.open(@base + "/" + g.attributes['location']) do |w|
          w.namespaces = {
            'wsdl' => 'http://www.w3.org/ns/wsdl',
            'plnk' => 'http://schemas.xmlsoap.org/ws/2003/05/partner-link/',
            'std'  => g.attributes['namespace'],
            'xsd'  => 'http://www.w3.org/2001/XMLSchema',
            'whttp' => 'http://www.w3.org/ns/wsdl/http'
          }
          w.find("/wsdl:description/plnk:partnerLinkType[@name='#{plnk_type}']/plnk:role[@name='#{plnk_role}']").each do |h|
            interface = remove_ns h.attributes['portType']
            method = w.find("string(/wsdl:description/wsdl:binding[@interface='#{interface}']/wsdl:operation[@ref='#{op}']/@whttp:method)")
            method = method == '' ? 'SOAP' : method
            w.find("/wsdl:description/wsdl:interface[@name='#{interface}']/wsdl:operation[@name='#{op}']/wsdl:input").each do |i|
              schema_nsn = extract_ns i.attributes['element'] 
              schema_root = remove_ns i.attributes['element']
              schema_ns = w.root.namespaces[schema_nsn]
              w.find("/wsdl:description/wsdl:types/xsd:schema[@targetNamespace='#{schema_ns}']/xsd:element[@name!='#{schema_root}']").delete_all!
              w.find("/wsdl:description/wsdl:types/xsd:schema[@targetNamespace='#{schema_ns}']").each do |s|
                node = result.root.add('invocation', 'plnk_name' => plnk_name, 'plnk_role' => plnk_role, 'plnk_type' => plnk_type, 'interface' => interface, 'method' => method, 'targetNamespace' => w.root.attributes['targetNamespace'])
                node.add(s)
              end
            end
          end
        end  
      end
    end
  end
  result.to_s
end