diff --git a/mozilla/extensions/webservices/proxy/Makefile.in b/mozilla/extensions/webservices/proxy/Makefile.in new file mode 100644 index 00000000000..191fba41575 --- /dev/null +++ b/mozilla/extensions/webservices/proxy/Makefile.in @@ -0,0 +1,31 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DIRS = public src + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/webservices/proxy/src/wspprivate.h b/mozilla/extensions/webservices/proxy/src/wspprivate.h new file mode 100644 index 00000000000..1e16ef4b873 --- /dev/null +++ b/mozilla/extensions/webservices/proxy/src/wspprivate.h @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Bandhauer (jband@netscape.com) + * Vidur Apparao (vidur@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __wspprivate_h__ +#define __wspprivate_h__ + +#include "nsIWebServiceProxy.h" +#include "nsIWSDL.h" + +// interface info includes +#include "xptcall.h" +#include "nsIInterfaceInfo.h" + +// XPCOM includes +#include "nsCOMPtr.h" +#include "nsSupportsArray.h" +#include "nsIPropertyBag.h" + +class nsISOAPCall; +class nsISOAPResponse; +class nsISOAPParameter; + +class WSPFactory : public nsIWebServiceProxyFactory +{ +public: + WSPFactory(); + virtual ~WSPFactory(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICEPROXYFACTORY +}; + +class WSPProxy : public nsXPTCStubBase, + public nsIWebServiceProxy, + public nsIClassInfo +{ +public: + WSPProxy(); + virtual ~WSPProxy(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICEPROXY + NS_DECL_NSICLASSINFO + + // Would be nice to have a NS_DECL_NSXPTCSTUBBASE + NS_IMETHOD CallMethod(PRUint16 methodIndex, + const nsXPTMethodInfo* info, + nsXPTCMiniVariant* params); + NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info); + + static nsresult Create(nsIWSDLPort* aPort, + nsIInterfaceInfo* aPrimaryInterface, + const nsAReadableString& aNamespace, + PRBool aIsAsync, WSPProxy** aProxy); + +protected: + nsCOMPtr mPort; + nsCOMPtr mPrimaryInterface; + nsString mNamespace; + PRBool mIsAsync; + nsSupportsArray mPendingCalls; +}; + +class WSPCallContext : public nsIWebServiceCallContext + // public nsISOAPResponseListener +{ +public: + WSPCallContext(); + virtual ~WSPCallContext(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICECALLCONTEXT + + static nsresult Create(WSPProxy* aProxy, + nsISOAPCall* aSOAPCall, + const nsAReadableString& aMethodName, + nsIWSDLOperation* aOperation, + WSPCallContext** aCallContext); + +protected: + nsCOMPtr mProxy; + // nsCOMPtr mSOAPCall; + nsString mMethodName; + nsCOMPtr mOperation; +}; + +class WSPComplexTypeWrapper : public nsIPropertyBag +{ +public: + WSPComplexTypeWrapper(); + virtual ~WSPComplexTypeWrapper(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIPROPERTYBAG + + static nsresult Create(nsISupports* aComplexTypeInstance, + nsIInterfaceInfo* aInterfaceInfo, + WSPComplexTypeWrapper** aWrapper); + +protected: + nsCOMPtr mComplexTypeInstance; + nsCOMPtr mInterfaceInfo; +}; + +class WSPPropertyBagWrapper : public nsXPTCStubBase +{ +public: + WSPPropertyBagWrapper(); + virtual ~WSPPropertyBagWrapper(); + + NS_DECL_ISUPPORTS + + // Would be nice to have a NS_DECL_NSXPTCSTUBBASE + NS_IMETHOD CallMethod(PRUint16 methodIndex, + const nsXPTMethodInfo* info, + nsXPTCMiniVariant* params); + NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info); + + static nsresult Create(nsIPropertyBag* aPropertyBag, + nsIInterfaceInfo* aInterfaceInfo, + WSPPropertyBagWrapper** aWrapper); + +protected: + nsCOMPtr mPropertyBag; + nsCOMPtr mInterfaceInfo; +}; + +#endif // __wspprivate_h__ diff --git a/mozilla/extensions/webservices/public/nsIWebServiceProxy.idl b/mozilla/extensions/webservices/public/nsIWebServiceProxy.idl new file mode 100644 index 00000000000..d99d4c82917 --- /dev/null +++ b/mozilla/extensions/webservices/public/nsIWebServiceProxy.idl @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Bandhauer (jband@netscape.com) + * Vidur Apparao (vidur@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" +#include "nsIWSDL.idl" +#include "nsIEnumerator.idl" +#include "nsIException.idl" + +%{ C++ +#include "nsAWritableString.h" +%} + +interface nsIWebServiceProxy; +interface nsIWebServiceProxyListener; +// XXX Should be replaced with an include +interface nsISOAPResponse; +interface nsISOAPParameter; + +[scriptable, uuid(693611be-bb38-40e0-a98e-b46ff8a5bcca)] +interface nsIWebServiceProxyFactory : nsISupports { + /** + * Create a service proxy. Loading of the WSDL URL will occur + * in a synchronous manner. Calls to web service can be made as + * soon as this method completes. + * + * @param wsdlURL The URL of the WSDL service description. This + * description will be loaded and used as the basis + * for the service proxy. + * @param portname The name of the port of the service that this + * service proxy represents. Currently the port + * must represent a SOAP binding. + * @param qualifier The user-specified qualifier is incorporated into + * the names of XPCOM interfaces created for the + * service proxy. For C++ callers, this qualifier + * should be the same one used in creating the IDL + * used at compile time. Script callers need not + * specify a qualifier. + * @param isAsync If PR_TRUE, the method signatures of the service + * proxy represent an asynchronous calling convention. + * A callback instance must be registered with the proxy. + * A method call to a web service is only completed when + * the corresponding callback method is invoked. + * If PR_FALSE, the method signatures of the service + * proxy represent a synchronous callling convention. + * A method call to a web service is completed when the + * method call to the proxy returns. + */ + nsIWebServiceProxy createProxy(in AString wsdlURL, in AString portname, + in AString qualifier, in boolean isAsync); + + /** + * Create a service proxy. Loading of the WSDL URL will occur + * in an asynchronous manner. Methods on the listener instance will + * be invoked when the proxy has been created. Any method invocations + * on the service proxy prior to asynchronous completion of the + * intialization step will fail. The caller is guaranteed that this + * method will return before the listener is invoked. + * + * @param wsdlURL The URL of the WSDL service description. This + * description will be loaded and used as the basis + * for the service proxy. + * @param portname The name of the port of the service that this + * service proxy represents. Currently the port + * must represent a SOAP binding. + * @param qualifier The user-specified qualifier is incorporated into + * the names of XPCOM interfaces created for the + * service proxy. For C++ callers, this qualifier + * should be the same one used in creating the IDL + * used at compile time. Script callers need not + * specify a qualifier. + * @param isAsync If PR_TRUE, the method signatures of the service + * proxy represent an asynchronous calling convention. + * A callback instance must be registered with the proxy. + * A method call to a web service is only completed when + * the corresponding callback method is invoked. + * If PR_FALSE, the method signatures of the service + * proxy represent a synchronous callling convention. + * A method call to a web service is completed when the + * method call to the proxy returns. + * @param listener The callback instance which will be invoked when + * the proxy is completely initialized. + */ + void createProxyAsync(in AString wsdlURL, in AString portname, + in AString qualifier, in boolean isAsync, + in nsIWebServiceProxyListener listener); +}; + +[scriptable, uuid(2122421c-1326-41db-87f8-25519d8a12cb)] +interface nsIWebServiceProxy : nsISupports { + /** + * The WSDL port that this service proxy represents. + * + * @see nsIWSDLPort + */ + readonly attribute nsIWSDLPort port; + + /** + * PR_TRUE if the service proxy methods represent an asynchronous + * calling convention. PR_FALSE if the methods are synchronous. + */ + readonly attribute boolean isAsync; + + /** + * The qualifier used for interface names related to + * this service proxy. + */ + readonly attribute AString qualifier; + + /** + * The collection of interfaces related to this service proxy. This + * will include the primary interface implemented by the service + * proxy as well as any listener or complex type interfaces required + * for method parameters and return values. + */ + // readonly attribute nsIXPCComponents_Interfaces interfaces; + + /** + * An enumerator that returns the set of pending calls for the + * service proxy. Each call is an instance of the + * nsIWebServiceCallContext interface. + * + * @see nsIWebServiceCallContext + */ + readonly attribute nsISimpleEnumerator pendingCalls; +}; + +/** + * This interface should be implemented by a user who creates + * a web service proxy in an asynchronous manner. An instance + * of this interface is passed into the initAsync + * method of the proxy. + */ +[scriptable, uuid(a711250b-47da-4f16-a1fd-593de16375a1)] +interface nsIWebServiceProxyListener : nsISupports { + /** + * Invoked when the proxy is completely initialized. Method + * calls on the proxy can be made once this method is called. + * + * @param proxy The initialized web service proxy + */ + void onLoad(in nsIWebServiceProxy proxy); + + /** + * Invoked if an error occurs during web service proxy + * initialization. This error code be a result of attempting + * to load the specified WSDL URL or a result of processing + * the WSDL and creating the interface information for the + * proxy. + * + * @param error The exception generated as a result of the + * error. This object can be introspected + * for further information. + */ + void onError(in nsIException error); +}; + +/** + * A representation of a method invocation on a web service. + * An instance of this interface is returned as a result of making + * an asynchronous call and can be queried for status of the + * call. + */ +[scriptable, uuid(87d87900-f102-4a15-b345-7b77a49d2df2)] +interface nsIWebServiceCallContext : nsISupports { + + /** + * Possible values of the status attribute. A pending + * call has a status of PENDING. A completed call has a status of + * SUCCEEDED or FAILED depending on the result of the call. + */ + const PRUint32 PENDING = 0; + const PRUint32 SUCCEEDED = 1; + const PRUint32 FAILED = 2; + const PRUint32 ABORTED = 3; + + /** + * The proxy object on which the call was made. + * + * @see nsIWebServiceProxy + */ + readonly attribute nsIWebServiceProxy proxy; + + /** + * The name of the method that was invoked. + */ + readonly attribute AString methodName; + + /** + * The status of the call, whether pending, completed successfully + * or completed with a fault. + */ + readonly attribute PRUint32 status; + + /** + * The exception generated by the call if the status is FAILURE. + * The exception object can be introspected for more information. + * The data member can be QIed to a + * nsISOAPFault instance for calls that use a + * SOAP binding. + */ + readonly attribute nsIException pendingException; + + /** + * The WSDL operation that correpsonds to the method being invoked. + * + * @see nsIWSDLOperation + */ + readonly attribute nsIWSDLOperation operation; + + /** + * For users who want access to the lower-level constructs that + * are used for the method invocation, this attributes provides + * the SOAP response once the call has completed. + * + * @see nsISOAPResponse + */ + readonly attribute nsISOAPResponse soapResponse; + + /** + * For user who want access to the lower-level constructs that + * are used for the method invocation, this method provides + * the SOAP parameters that were passed to the lower-level API. + * + * @see nsISOAPParameter + * @param paramCount The number of parameters in the array. + * @param params The array of parameters passed to the + * lower-level API. + */ + void getParameters(out PRUint32 paramCount, [retval, array, size_is(paramCount)] out nsISOAPParameter params); + + /** + * For user who want access to the lower-level constructs that + * are used for the method invocation, this method provides + * the SOAP parameters that were returned from the call + * to the lower-level API. This list is only available after + * the call completes successfully. + * + * @see nsISOAPParameter + * @param resultCount The number of results in the array. + * @param results The array of results returned from the + * lower-level API. + */ + void getResults(out PRUint32 resultCount, [retval, array, size_is(resultCount)] out nsISOAPParameter results); + + /** + * Called to abort a pending call. If the call is still pending, + * its callback instance's onError will be invoked, + * passing in the specified exception. + * + * @param error The exception passed to the callback instance's + * onError method. + */ + void abort(in nsIException error); +}; + diff --git a/mozilla/extensions/xmlextras/proxy/Makefile.in b/mozilla/extensions/xmlextras/proxy/Makefile.in new file mode 100644 index 00000000000..191fba41575 --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/Makefile.in @@ -0,0 +1,31 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DIRS = public src + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/xmlextras/proxy/makefile.win b/mozilla/extensions/xmlextras/proxy/makefile.win new file mode 100755 index 00000000000..09d593e23d0 --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/makefile.win @@ -0,0 +1,26 @@ +#!nmake +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\.. + +DIRS=public src + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/extensions/xmlextras/proxy/public/Makefile.in b/mozilla/extensions/xmlextras/proxy/public/Makefile.in new file mode 100644 index 00000000000..5a573fcd3da --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/public/Makefile.in @@ -0,0 +1,36 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = xmlextras +XPIDL_MODULE = wsproxy + +XPIDLSRCS = \ + nsIWebServiceProxy.idl \ + $(NULL) + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/extensions/xmlextras/proxy/public/makefile.win b/mozilla/extensions/xmlextras/proxy/public/makefile.win new file mode 100755 index 00000000000..a6934d21dfe --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/public/makefile.win @@ -0,0 +1,30 @@ +#!nmake +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. + +XPIDLSRCS = .\nsIWebServiceProxy.idl \ + $(NULL) + +MODULE=xmlextras +XPIDL_MODULE=wsproxy + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/extensions/xmlextras/proxy/public/nsIWebServiceProxy.idl b/mozilla/extensions/xmlextras/proxy/public/nsIWebServiceProxy.idl new file mode 100644 index 00000000000..d99d4c82917 --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/public/nsIWebServiceProxy.idl @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Bandhauer (jband@netscape.com) + * Vidur Apparao (vidur@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" +#include "nsIWSDL.idl" +#include "nsIEnumerator.idl" +#include "nsIException.idl" + +%{ C++ +#include "nsAWritableString.h" +%} + +interface nsIWebServiceProxy; +interface nsIWebServiceProxyListener; +// XXX Should be replaced with an include +interface nsISOAPResponse; +interface nsISOAPParameter; + +[scriptable, uuid(693611be-bb38-40e0-a98e-b46ff8a5bcca)] +interface nsIWebServiceProxyFactory : nsISupports { + /** + * Create a service proxy. Loading of the WSDL URL will occur + * in a synchronous manner. Calls to web service can be made as + * soon as this method completes. + * + * @param wsdlURL The URL of the WSDL service description. This + * description will be loaded and used as the basis + * for the service proxy. + * @param portname The name of the port of the service that this + * service proxy represents. Currently the port + * must represent a SOAP binding. + * @param qualifier The user-specified qualifier is incorporated into + * the names of XPCOM interfaces created for the + * service proxy. For C++ callers, this qualifier + * should be the same one used in creating the IDL + * used at compile time. Script callers need not + * specify a qualifier. + * @param isAsync If PR_TRUE, the method signatures of the service + * proxy represent an asynchronous calling convention. + * A callback instance must be registered with the proxy. + * A method call to a web service is only completed when + * the corresponding callback method is invoked. + * If PR_FALSE, the method signatures of the service + * proxy represent a synchronous callling convention. + * A method call to a web service is completed when the + * method call to the proxy returns. + */ + nsIWebServiceProxy createProxy(in AString wsdlURL, in AString portname, + in AString qualifier, in boolean isAsync); + + /** + * Create a service proxy. Loading of the WSDL URL will occur + * in an asynchronous manner. Methods on the listener instance will + * be invoked when the proxy has been created. Any method invocations + * on the service proxy prior to asynchronous completion of the + * intialization step will fail. The caller is guaranteed that this + * method will return before the listener is invoked. + * + * @param wsdlURL The URL of the WSDL service description. This + * description will be loaded and used as the basis + * for the service proxy. + * @param portname The name of the port of the service that this + * service proxy represents. Currently the port + * must represent a SOAP binding. + * @param qualifier The user-specified qualifier is incorporated into + * the names of XPCOM interfaces created for the + * service proxy. For C++ callers, this qualifier + * should be the same one used in creating the IDL + * used at compile time. Script callers need not + * specify a qualifier. + * @param isAsync If PR_TRUE, the method signatures of the service + * proxy represent an asynchronous calling convention. + * A callback instance must be registered with the proxy. + * A method call to a web service is only completed when + * the corresponding callback method is invoked. + * If PR_FALSE, the method signatures of the service + * proxy represent a synchronous callling convention. + * A method call to a web service is completed when the + * method call to the proxy returns. + * @param listener The callback instance which will be invoked when + * the proxy is completely initialized. + */ + void createProxyAsync(in AString wsdlURL, in AString portname, + in AString qualifier, in boolean isAsync, + in nsIWebServiceProxyListener listener); +}; + +[scriptable, uuid(2122421c-1326-41db-87f8-25519d8a12cb)] +interface nsIWebServiceProxy : nsISupports { + /** + * The WSDL port that this service proxy represents. + * + * @see nsIWSDLPort + */ + readonly attribute nsIWSDLPort port; + + /** + * PR_TRUE if the service proxy methods represent an asynchronous + * calling convention. PR_FALSE if the methods are synchronous. + */ + readonly attribute boolean isAsync; + + /** + * The qualifier used for interface names related to + * this service proxy. + */ + readonly attribute AString qualifier; + + /** + * The collection of interfaces related to this service proxy. This + * will include the primary interface implemented by the service + * proxy as well as any listener or complex type interfaces required + * for method parameters and return values. + */ + // readonly attribute nsIXPCComponents_Interfaces interfaces; + + /** + * An enumerator that returns the set of pending calls for the + * service proxy. Each call is an instance of the + * nsIWebServiceCallContext interface. + * + * @see nsIWebServiceCallContext + */ + readonly attribute nsISimpleEnumerator pendingCalls; +}; + +/** + * This interface should be implemented by a user who creates + * a web service proxy in an asynchronous manner. An instance + * of this interface is passed into the initAsync + * method of the proxy. + */ +[scriptable, uuid(a711250b-47da-4f16-a1fd-593de16375a1)] +interface nsIWebServiceProxyListener : nsISupports { + /** + * Invoked when the proxy is completely initialized. Method + * calls on the proxy can be made once this method is called. + * + * @param proxy The initialized web service proxy + */ + void onLoad(in nsIWebServiceProxy proxy); + + /** + * Invoked if an error occurs during web service proxy + * initialization. This error code be a result of attempting + * to load the specified WSDL URL or a result of processing + * the WSDL and creating the interface information for the + * proxy. + * + * @param error The exception generated as a result of the + * error. This object can be introspected + * for further information. + */ + void onError(in nsIException error); +}; + +/** + * A representation of a method invocation on a web service. + * An instance of this interface is returned as a result of making + * an asynchronous call and can be queried for status of the + * call. + */ +[scriptable, uuid(87d87900-f102-4a15-b345-7b77a49d2df2)] +interface nsIWebServiceCallContext : nsISupports { + + /** + * Possible values of the status attribute. A pending + * call has a status of PENDING. A completed call has a status of + * SUCCEEDED or FAILED depending on the result of the call. + */ + const PRUint32 PENDING = 0; + const PRUint32 SUCCEEDED = 1; + const PRUint32 FAILED = 2; + const PRUint32 ABORTED = 3; + + /** + * The proxy object on which the call was made. + * + * @see nsIWebServiceProxy + */ + readonly attribute nsIWebServiceProxy proxy; + + /** + * The name of the method that was invoked. + */ + readonly attribute AString methodName; + + /** + * The status of the call, whether pending, completed successfully + * or completed with a fault. + */ + readonly attribute PRUint32 status; + + /** + * The exception generated by the call if the status is FAILURE. + * The exception object can be introspected for more information. + * The data member can be QIed to a + * nsISOAPFault instance for calls that use a + * SOAP binding. + */ + readonly attribute nsIException pendingException; + + /** + * The WSDL operation that correpsonds to the method being invoked. + * + * @see nsIWSDLOperation + */ + readonly attribute nsIWSDLOperation operation; + + /** + * For users who want access to the lower-level constructs that + * are used for the method invocation, this attributes provides + * the SOAP response once the call has completed. + * + * @see nsISOAPResponse + */ + readonly attribute nsISOAPResponse soapResponse; + + /** + * For user who want access to the lower-level constructs that + * are used for the method invocation, this method provides + * the SOAP parameters that were passed to the lower-level API. + * + * @see nsISOAPParameter + * @param paramCount The number of parameters in the array. + * @param params The array of parameters passed to the + * lower-level API. + */ + void getParameters(out PRUint32 paramCount, [retval, array, size_is(paramCount)] out nsISOAPParameter params); + + /** + * For user who want access to the lower-level constructs that + * are used for the method invocation, this method provides + * the SOAP parameters that were returned from the call + * to the lower-level API. This list is only available after + * the call completes successfully. + * + * @see nsISOAPParameter + * @param resultCount The number of results in the array. + * @param results The array of results returned from the + * lower-level API. + */ + void getResults(out PRUint32 resultCount, [retval, array, size_is(resultCount)] out nsISOAPParameter results); + + /** + * Called to abort a pending call. If the call is still pending, + * its callback instance's onError will be invoked, + * passing in the specified exception. + * + * @param error The exception passed to the callback instance's + * onError method. + */ + void abort(in nsIException error); +}; + diff --git a/mozilla/extensions/xmlextras/proxy/src/makefile.win b/mozilla/extensions/xmlextras/proxy/src/makefile.win new file mode 100755 index 00000000000..5d4db8cbce7 --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/src/makefile.win @@ -0,0 +1,54 @@ +#!nmake +# +# The contents of this file are subject to the Netscape Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/NPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\..\.. + +LIBRARY_NAME=xmlextrasproxy_s +MODULE=xmlextras + +DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN + +REQUIRES = xpcom \ + string \ + xpconnect \ + caps \ + js \ + necko \ + $(NULL) + +CPPSRCS= \ + wspProxy.cpp \ + $(NULL) + +CPP_OBJS= \ + .\$(OBJDIR)\wspProxy.obj \ + $(NULL) + +EXPORTS = \ + $(NULL) + +include <$(DEPTH)\config\rules.mak> + +install:: $(LIBRARY) + $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib + +clobber:: + rm -f $(DIST)\lib\$(LIBRARY_NAME).lib diff --git a/mozilla/extensions/xmlextras/proxy/src/wspprivate.h b/mozilla/extensions/xmlextras/proxy/src/wspprivate.h new file mode 100644 index 00000000000..1e16ef4b873 --- /dev/null +++ b/mozilla/extensions/xmlextras/proxy/src/wspprivate.h @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Bandhauer (jband@netscape.com) + * Vidur Apparao (vidur@netscape.com) + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __wspprivate_h__ +#define __wspprivate_h__ + +#include "nsIWebServiceProxy.h" +#include "nsIWSDL.h" + +// interface info includes +#include "xptcall.h" +#include "nsIInterfaceInfo.h" + +// XPCOM includes +#include "nsCOMPtr.h" +#include "nsSupportsArray.h" +#include "nsIPropertyBag.h" + +class nsISOAPCall; +class nsISOAPResponse; +class nsISOAPParameter; + +class WSPFactory : public nsIWebServiceProxyFactory +{ +public: + WSPFactory(); + virtual ~WSPFactory(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICEPROXYFACTORY +}; + +class WSPProxy : public nsXPTCStubBase, + public nsIWebServiceProxy, + public nsIClassInfo +{ +public: + WSPProxy(); + virtual ~WSPProxy(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICEPROXY + NS_DECL_NSICLASSINFO + + // Would be nice to have a NS_DECL_NSXPTCSTUBBASE + NS_IMETHOD CallMethod(PRUint16 methodIndex, + const nsXPTMethodInfo* info, + nsXPTCMiniVariant* params); + NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info); + + static nsresult Create(nsIWSDLPort* aPort, + nsIInterfaceInfo* aPrimaryInterface, + const nsAReadableString& aNamespace, + PRBool aIsAsync, WSPProxy** aProxy); + +protected: + nsCOMPtr mPort; + nsCOMPtr mPrimaryInterface; + nsString mNamespace; + PRBool mIsAsync; + nsSupportsArray mPendingCalls; +}; + +class WSPCallContext : public nsIWebServiceCallContext + // public nsISOAPResponseListener +{ +public: + WSPCallContext(); + virtual ~WSPCallContext(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIWEBSERVICECALLCONTEXT + + static nsresult Create(WSPProxy* aProxy, + nsISOAPCall* aSOAPCall, + const nsAReadableString& aMethodName, + nsIWSDLOperation* aOperation, + WSPCallContext** aCallContext); + +protected: + nsCOMPtr mProxy; + // nsCOMPtr mSOAPCall; + nsString mMethodName; + nsCOMPtr mOperation; +}; + +class WSPComplexTypeWrapper : public nsIPropertyBag +{ +public: + WSPComplexTypeWrapper(); + virtual ~WSPComplexTypeWrapper(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIPROPERTYBAG + + static nsresult Create(nsISupports* aComplexTypeInstance, + nsIInterfaceInfo* aInterfaceInfo, + WSPComplexTypeWrapper** aWrapper); + +protected: + nsCOMPtr mComplexTypeInstance; + nsCOMPtr mInterfaceInfo; +}; + +class WSPPropertyBagWrapper : public nsXPTCStubBase +{ +public: + WSPPropertyBagWrapper(); + virtual ~WSPPropertyBagWrapper(); + + NS_DECL_ISUPPORTS + + // Would be nice to have a NS_DECL_NSXPTCSTUBBASE + NS_IMETHOD CallMethod(PRUint16 methodIndex, + const nsXPTMethodInfo* info, + nsXPTCMiniVariant* params); + NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info); + + static nsresult Create(nsIPropertyBag* aPropertyBag, + nsIInterfaceInfo* aInterfaceInfo, + WSPPropertyBagWrapper** aWrapper); + +protected: + nsCOMPtr mPropertyBag; + nsCOMPtr mInterfaceInfo; +}; + +#endif // __wspprivate_h__