[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at dev.open-bio.org
Thu Dec 7 17:23:41 UTC 2006
mwilkinson
Thu Dec 7 12:23:41 EST 2006
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory dev.open-bio.org:/tmp/cvs-serv29991/MOBY
Modified Files:
Central.pm
Log Message:
untested. It should now handle POST services and create valid POST WSDL. not tested.
moby-live/Perl/MOBY Central.pm,1.263,1.264
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -r1.263 -r1.264
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2006/12/07 16:18:04 1.263
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2006/12/07 17:23:41 1.264
@@ -9,7 +9,7 @@
package MOBY::Central;
use strict;
use Carp;
-use vars qw($AUTOLOAD $WSDL_TEMPLATE);
+use vars qw($AUTOLOAD $WSDL_TEMPLATE $WSDL_POST_TEMPLATE);
use XML::LibXML;
use MOBY::OntologyServer;
use MOBY::service_type;
@@ -3201,11 +3201,52 @@
# the lines below causes no end of grief. It is now in a variable.
#open (WSDL, "./MOBY/Central_WSDL_SandR.wsdl") || die "can't open WSDL file for search and replace\n";
#my $wsdl = join "", (<WSDL>);
- my $wsdl = $WSDL_TEMPLATE;
- $wsdl =~ s/^\n//gs;
#close WSDL;
# do substitutions
+ my $serviceType = $SI->category;
+ my $wsdl;
+ if ($serviceType eq "post"){
+ $wsdl = &_doPostWSDLReplacement(@_)
+ } elsif ($serviceType eq "moby"){
+ $wsdl = &_doMobyWSDLReplacement(@_)
+ }
+ return $wsdl;
+}
+
+sub _doPostWSDLReplacement {
+ my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
+ my $wsdl = $WSDL_POST_TEMPLATE;
+ $wsdl =~ s/^\n//gs;
+ my $serviceName = $SI->servicename;
+ my $AuthURI = $SI->authority_uri;
+ my $desc = $SI->description;
+ if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+ $desc = $1;
+ }
+ $desc =~ s"\<"<"g; # XMl encode now that it is not CDATAd
+ $desc =~ s"\>">"g; # XML encode now that it is not CDATAd
+ my $URL = $SI->url;
+ $URL =~ "http://(^/+)/(.*)";
+ my $baseURL = $1;
+ my $relativeURL = $2;
+ my $IN = "NOT_YET_DEFINED_INPUTS";
+ my $OUT = "NOT_YET_DEFINED_OUTPUTS";
+ my $INxsd = &_getInputXSD( $InputXML, $SecondaryXML );
+ my $OUTxsd = &_getOutputXSD($OutputXML);
+ $INxsd ||= "<NOT_YET_IMPLEMENTED_INPUT_XSD/>";
+ $OUTxsd ||= "<NOT_YET_IMPLEMENTED_OUTPUT_XSD/>";
+ $wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
+ $wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
+ $wsdl =~ s/MOBY__SERVICE__URL/$baseURL/g; # the URL to the service
+ $wsdl =~ s/MOBY__SERVICE__POST/$relativeURL/g; # the URL to the service
+ $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
+}
+
+sub _doMobyWSDLReplacement {
+ my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
+ my $wsdl = $WSDL_TEMPLATE;
+ $wsdl =~ s/^\n//gs;
my $serviceName = $SI->servicename;
my $AuthURI = $SI->authority_uri;
my $desc = $SI->description;
@@ -3224,16 +3265,11 @@
$wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
$wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
$wsdl =~ s/MOBY__SERVICE__URL/$URL/g; # the URL to the service
- #if (scalar @in){my ($IN, $INxsd) = @{shift @in}};
- #if (scalar @out){my ($OUT, $OUTxsd) = @{shift @out}};
-# $wsdl =~ s/MOBY__INPUT__OBJECT__NAME/$IN/g; # SINGLE input object (for now)
-# $wsdl =~ s/MOBY__OUTPUT__OBJECT__NAME/$OUT/g; # SINGLE output object (for now)
-# $wsdl =~ s/\<\!\-\-\s*MOBY__INPUT__OBJECT__XSD\s*\-\-\>/$INxsd/g; # XSD stright from the database
-# $wsdl =~ s/\<\!\-\-\s*MOBY__OUTPUT__OBJECT__XSD\s*\-\-\>/$OUTxsd/g; # XSD straight from the database
- $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
- return $wsdl;
+ $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
+ return $wsdl
}
+
#sub _getCGIService {
# my ( $dbh, $sth_hash, $id, $serviceName, $AuthURI, $URL, $desc, $category )
# = @_;
@@ -3808,6 +3844,61 @@
END
+
+
+$WSDL_POST_TEMPLATE = <<END;
+<?xml version="1.0"?>
+<wsdl:definitions name="MOBY_Central_Generated_WSDL"
+ targetNamespace="http://biomoby.org/Central.wsdl"
+ xmlns:tns="http://biomoby.org/Central.wsdl"
+ xmlns:xsd1="http://biomoby.org/CentralXSDs.xsd"
+ xmlns:xsd="http://www.w3.org/1999/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+
+
+ <wsdl:message name="MOBY__SERVICE__NAME__Input">
+ <wsdl:part name="data" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:message name="MOBY__SERVICE__NAME__Output">
+ <wsdl:part name="body" type="xsd:string"/>
+ </wsdl:message>
+
+ <wsdl:portType name="MOBY__SERVICE__NAME__PortType">
+ <wsdl:operation name="MOBY__SERVICE__NAME">
+ <wsdl:input message="tns:MOBY__SERVICE__NAME__Input"/>
+ <wsdl:output message="tns:MOBY__SERVICE__NAME__Output"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="MOBY__SERVICE__NAME__Binding" type="tns:MOBY__SERVICE__NAME__PortType">
+ <http:binding verb="POST"/>
+ <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
+ <http:operation location='MOBY__SERVICE__POST'/>
+ <wsdl:input>
+ <mime:content type="application/x-www-form-urlencoded">
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="MOBY__SERVICE__NAME__Service">
+ <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation> <!-- service description goes here -->
+ <wsdl:port name="MOBY__SERVICE__NAME__Port" binding="tns:MOBY__SERVICE__NAME__Binding">
+ <http:address location="MOBY__SERVICE__URL"/> <!-- URL to service scriptname -->
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
+
+
+END
+
+
=head2 _getInputXSD
name : _getInputXSD($InputXML, $SecondaryXML)
More information about the MOBY-guts
mailing list