bug 249366 : Better error handling for webservices. patch chantepie@altern.org, r=me sr=jst

This commit is contained in:
hpradhan%hotpop.com 2004-09-16 10:59:36 +00:00
Родитель 89deaaa3b4
Коммит 47e5b5d1f8
25 изменённых файлов: 1034 добавлений и 219 удалений

Просмотреть файл

@ -41,6 +41,7 @@
// NSPR includes
#include "prprf.h"
#include "nsIWebServiceErrorHandler.h"
/***************************************************************************/
class WSPAsyncProxyCreator : public nsIWSDLLoadListener
@ -51,6 +52,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWSDLLOADLISTENER
NS_DECL_NSIWEBSERVICEERRORHANDLER
nsresult Run(const nsAString & wsdlURL, const nsAString & portname,
const nsAString & qualifier, PRBool isAsync,
@ -73,7 +75,9 @@ WSPAsyncProxyCreator::~WSPAsyncProxyCreator()
// do nothing...
}
NS_IMPL_ISUPPORTS1(WSPAsyncProxyCreator, nsIWSDLLoadListener)
NS_IMPL_ISUPPORTS2(WSPAsyncProxyCreator,
nsIWSDLLoadListener,
nsIWebServiceErrorHandler);
nsresult
WSPAsyncProxyCreator::Run(const nsAString& wsdlURL, const nsAString& portname,

Просмотреть файл

@ -102,7 +102,7 @@ WSPProxy::Init(nsIWSDLPort* aPort, nsIInterfaceInfo* aPrimaryInterface,
return NS_ERROR_FAILURE;
}
rv = mPrimaryInterface->GetInfoForParam(3, &listenerParam,
getter_AddRefs(mListenerInterfaceInfo));
getter_AddRefs(mListenerInterfaceInfo));
if (NS_FAILED(rv)) {
return rv;
}
@ -158,6 +158,22 @@ WSPProxy::QueryInterface(REFNSIID aIID, void** aInstancePtr)
// Implementation of nsXPTCStubBase methods
//
///////////////////////////////////////////////////
/**
* Asynchronous processing :
* 1-> WSPProxy::CallMethod
* 2 -> WSPCallContext::CallAsync
* 3 -> nsSOAPCall::AsyncInvoke
* 4 -> nsXXXSOAPTransport::AsyncCall
* 5 -> nsIXMLHttpRequest::Send, nsXXXSOAPTransportCompletion::AddEventListener
* ---- asynchronous ----
* 6 -> nsXXXSOAPTransportCompletion::HandleEvent
* 7 -> WSPCallContext::HandleResponse,
* WSPCallContext::CallCompletionListener
* 8 -> nsSOAPBlock::SetSchemaType, nsSOAPBlock::GetValue
* 9 -> nsSOAPEncoding::Decode, nsDefaultSOAPDecode::Decode
* 10 -> WSPProxy::CallCompleted
*/
NS_IMETHODIMP
WSPProxy::CallMethod(PRUint16 methodIndex,
const nsXPTMethodInfo* info,
@ -385,8 +401,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
nsCOMPtr<nsISchemaType> type;
nsAutoString blockName, blockNamespace;
nsCOMPtr<nsISchemaElement> element = do_QueryInterface(schemaComponent);
if (element) {
rv = element->GetType(getter_AddRefs(type));
if (NS_FAILED(rv)) {

Просмотреть файл

@ -70,9 +70,10 @@ WSPProxyTest::~WSPProxyTest()
{
}
NS_IMPL_ISUPPORTS3_CI(WSPProxyTest,
NS_IMPL_ISUPPORTS4_CI(WSPProxyTest,
nsIWSPProxyTest,
nsIWSDLLoadListener,
nsIWebServiceErrorHandler,
SpheonJSAOPStatisticsPortTypeListener)
nsresult

Просмотреть файл

@ -55,6 +55,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWSPPROXYTEST
NS_DECL_NSIWSDLLOADLISTENER
NS_DECL_NSIWEBSERVICEERRORHANDLER
NS_DECL_SPHEONJSAOPSTATISTICSPORTTYPELISTENER
protected:

Просмотреть файл

@ -46,6 +46,10 @@ MODULE = websrvcs
XPIDL_MODULE = websrvcs
XPIDLSRCS = \
nsIWebServiceErrorHandler.idl \
$(NULL)
XPIDLSRCS += \
nsISOAPAttachments.idl \
nsISOAPBlock.idl \
nsISOAPBlock.idl \

Просмотреть файл

@ -37,10 +37,6 @@
#include "nsISupports.idl"
%{ C++
#include "nsAString.h"
%}
interface nsIDOMElement;
/**

Просмотреть файл

@ -37,10 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{ C++
#include "nsAString.h"
%}
#include "nsIWebServiceErrorHandler.idl"
interface nsISchema;
interface nsISchemaType;
@ -73,10 +70,10 @@ interface nsISchemaCollection : nsISupports {
nsISchemaType getType(in AString name, in AString aNamespace);
};
[scriptable, uuid(3c14a020-6f4e-11d5-9b46-000064657374)]
[scriptable, uuid(5caaa64e-e191-11d8-842a-000393b6661a)]
interface nsISchemaComponent : nsISupports {
readonly attribute AString targetNamespace;
void resolve();
void resolve(in nsIWebServiceErrorHandler aErrorHandler);
void clear();
};

Просмотреть файл

@ -37,25 +37,25 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIWebServiceErrorHandler.idl"
interface nsISchema;
interface nsISchemaType;
interface nsIDOMElement;
interface nsISchemaLoadListener;
[scriptable, uuid(3c14a032-6f4e-11d5-9b46-000064657374)]
[scriptable, uuid(77061d1d-e191-11d8-a3cc-000393b6661a)]
interface nsISchemaLoader : nsISupports {
nsISchema load(in AString schemaURI);
void loadAsync(in AString schemaURI,
in nsISchemaLoadListener listener);
nsISchema processSchemaElement(in nsIDOMElement element);
nsISchema processSchemaElement(in nsIWebServiceErrorHandler aErrorHandler,
in nsIDOMElement element);
};
[scriptable, function, uuid(3c14a033-6f4e-11d5-9b46-000064657374)]
interface nsISchemaLoadListener : nsISupports {
[scriptable, function, uuid(8d9aa9ce-e191-11d8-9f31-000393b6661a)]
interface nsISchemaLoadListener : nsIWebServiceErrorHandler {
void onLoad(in nsISchema schema);
void onError(in PRInt32 status,
in AString statusMessage);
};
%{ C++

Просмотреть файл

@ -39,10 +39,6 @@
#include "nsISupports.idl"
#include "nsISchema.idl"
%{ C++
#include "nsAString.h"
%}
interface nsIWSDLBinding;
interface nsIWSDLPort;
interface nsIWSDLOperation;

Просмотреть файл

@ -37,10 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{ C++
#include "nsAString.h"
%}
#include "nsIWebServiceErrorHandler.idl"
interface nsIWSDLPort;
interface nsIWSDLLoadListener;
@ -55,11 +52,10 @@ interface nsIWSDLLoader : nsISupports
in nsIWSDLLoadListener listener);
};
[scriptable, uuid(0458dac6-65de-11d5-9b42-00104bdf5339)]
interface nsIWSDLLoadListener : nsISupports
[scriptable, uuid(c3681210-e191-11d8-949e-000393b6661a)]
interface nsIWSDLLoadListener : nsIWebServiceErrorHandler
{
void onLoad(in nsIWSDLPort port);
void onError(in nsresult status, in AString statusMessage);
};
%{ C++

Просмотреть файл

@ -39,10 +39,6 @@
#include "nsISupports.idl"
#include "nsIWSDL.idl"
%{ C++
#include "nsAString.h"
%}
[scriptable, uuid(bb76b72e-d143-4738-804a-53b311466dd9)]
interface nsIWSDLSOAPBinding : nsIWSDLBinding
{

Просмотреть файл

@ -42,10 +42,6 @@
#include "nsIInterfaceInfoManager.idl"
#include "nsIWSDL.idl"
%{ C++
#include "nsAString.h"
%}
[scriptable, uuid(8c7bf4bc-d3fe-4524-b213-ce578bfe936e)]
interface nsIWSPInterfaceInfoService : nsISupports
{

Просмотреть файл

@ -45,10 +45,6 @@
#include "nsISOAPBlock.idl"
#include "nsIScriptableInterfaces.idl"
%{ C++
#include "nsAString.h"
%}
interface nsIWebServiceProxy;
interface nsIWebServiceProxyCreationListener;
interface nsIInterfaceInfo;

Просмотреть файл

@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSchemaPrivate.h"
#include "nsIWebServiceErrorHandler.h"
nsSOAPArray::nsSOAPArray(nsISchemaType* aAnyType)
: mAnyType(aAnyType)
@ -60,9 +61,9 @@ nsSOAPArray::GetTargetNamespace(nsAString& aTargetNamespace)
return NS_OK;
}
/* void resolve(); */
/* void resolve(in nsIWebServiceErrorHandler); */
NS_IMETHODIMP
nsSOAPArray::Resolve()
nsSOAPArray::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}
@ -224,9 +225,9 @@ nsSOAPArrayType::GetTargetNamespace(nsAString& aTargetNamespace)
return NS_OK;
}
/* void resolve(); */
/* void resolve(in nsIWebServiceErrorHandler); */
NS_IMETHODIMP
nsSOAPArrayType::Resolve()
nsSOAPArrayType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}

Просмотреть файл

@ -109,39 +109,87 @@ nsSchema::GetSchemaNamespace(nsAString& aSchemaNamespace)
}
NS_IMETHODIMP
nsSchema::Resolve()
nsSchema::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
nsresult rv;
PRUint32 i, count;
count = mTypes.Count();
for (i = 0; i < count; ++i) {
rv = mTypes.ObjectAt(i)->Resolve();
rv = mTypes.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString name;
nsresult rc = mTypes.ObjectAt(i)->GetName(name);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema, cannot resolve schema type \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
}
NS_ENSURE_SUCCESS(rv, rv);
}
count = mAttributes.Count();
for (i = 0; i < count; ++i) {
rv = mAttributes.ObjectAt(i)->Resolve();
rv = mAttributes.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString name;
nsresult rc = mAttributes.ObjectAt(i)->GetName(name);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema, cannot resolve attribute \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
}
NS_ENSURE_SUCCESS(rv, rv);
}
count = mElements.Count();
for (i = 0; i < count; ++i) {
rv = mElements.ObjectAt(i)->Resolve();
rv = mElements.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString name;
nsresult rc = mElements.ObjectAt(i)->GetName(name);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema, cannot resolve element \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
}
NS_ENSURE_SUCCESS(rv, rv);
}
count = mAttributeGroups.Count();
for (i = 0; i < count; ++i) {
rv = mAttributeGroups.ObjectAt(i)->Resolve();
NS_ENSURE_SUCCESS(rv, rv);
rv = mAttributeGroups.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure resolving schema, "));
errorMsg.AppendLiteral("cannot resolve attribute groups");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
count = mModelGroups.Count();
for (i = 0; i < count; ++i) {
rv = mModelGroups.ObjectAt(i)->Resolve();
NS_ENSURE_SUCCESS(rv, rv);
rv = mModelGroups.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure resolving schema, "));
errorMsg.AppendLiteral("cannot resolve model group");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
return NS_OK;
@ -451,7 +499,8 @@ nsSchema::DropCollectionReference()
}
nsresult
nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsSchema::ResolveTypePlaceholder(nsIWebServiceErrorHandler* aErrorHandler,
nsISchemaType* aPlaceholder,
nsISchemaType** aType)
{
PRUint16 schemaType;
@ -464,6 +513,13 @@ nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsresult rv = GetTypeByName(name, aType);
if (NS_FAILED(rv) || !*aType) {
*aType = nsnull;
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema type, ");
errorMsg.AppendLiteral("cannot resolve schema type place holder for \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -59,9 +59,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAttribute,
nsISchemaAttribute)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAttribute::Resolve()
nsSchemaAttribute::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -71,7 +71,7 @@ nsSchemaAttribute::Resolve()
nsresult rv = NS_OK;
if (mType && mSchema) {
nsCOMPtr<nsISchemaType> type;
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mType, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
@ -79,7 +79,7 @@ nsSchemaAttribute::Resolve()
if (!mType) {
return NS_ERROR_FAILURE;
}
rv = mType->Resolve();
rv = mType->Resolve(aErrorHandler);
}
return rv;
@ -211,9 +211,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAttributeRef,
nsISchemaAttribute)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAttributeRef::Resolve()
nsSchemaAttributeRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
nsresult rv = NS_OK;
if (mIsResolved) {
@ -226,7 +226,7 @@ nsSchemaAttributeRef::Resolve()
}
if (mAttribute) {
rv = mAttribute->Resolve();
rv = mAttribute->Resolve(aErrorHandler);
}
return rv;
@ -351,9 +351,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAttributeGroup,
nsISchemaAttributeComponent,
nsISchemaAttributeGroup)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAttributeGroup::Resolve()
nsSchemaAttributeGroup::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -365,7 +365,7 @@ nsSchemaAttributeGroup::Resolve()
count = mAttributes.Count();
for (i = 0; i < count; ++i) {
rv = mAttributes.ObjectAt(i)->Resolve();
rv = mAttributes.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
return rv;
}
@ -488,9 +488,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAttributeGroupRef,
nsISchemaAttributeComponent,
nsISchemaAttributeGroup)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAttributeGroupRef::Resolve()
nsSchemaAttributeGroupRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
nsresult rv = NS_OK;
if (mIsResolved) {
@ -503,7 +503,7 @@ nsSchemaAttributeGroupRef::Resolve()
}
if (mAttributeGroup) {
rv = mAttributeGroup->Resolve();
rv = mAttributeGroup->Resolve(aErrorHandler);
}
return rv;
@ -608,9 +608,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAnyAttribute,
nsISchemaAttributeComponent,
nsISchemaAnyAttribute)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAnyAttribute::Resolve()
nsSchemaAnyAttribute::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaComplexType,
nsISchemaType,
nsISchemaComplexType)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler* aErrorHandler); */
NS_IMETHODIMP
nsSchemaComplexType::Resolve()
nsSchemaComplexType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -75,8 +75,20 @@ nsSchemaComplexType::Resolve()
count = mAttributes.Count();
for (i = 0; i < count; ++i) {
rv = mAttributes.ObjectAt(i)->Resolve();
rv = mAttributes.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString attrName;
nsresult rv1 = mAttributes.ObjectAt(i)->GetName(attrName);
NS_ENSURE_SUCCESS(rv1, rv1);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema complex type, ");
errorMsg.AppendLiteral("cannot resolve attribute \"");
errorMsg.Append(attrName);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
@ -87,19 +99,30 @@ nsSchemaComplexType::Resolve()
nsCOMPtr<nsISchemaType> type;
if (mBaseType) {
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mBaseType, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
mBaseType = type;
rv = mBaseType->Resolve();
rv = mBaseType->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString baseStr;
nsresult rv1 = type->GetName(baseStr);
NS_ENSURE_SUCCESS(rv1, rv1);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema complex type, ");
errorMsg.AppendLiteral("cannot resolve base type \"");
errorMsg.Append(baseStr);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return NS_ERROR_FAILURE;
}
}
if (mSimpleBaseType) {
rv = mSchema->ResolveTypePlaceholder(mSimpleBaseType,
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mSimpleBaseType,
getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
@ -108,15 +131,27 @@ nsSchemaComplexType::Resolve()
if (!mSimpleBaseType) {
return NS_ERROR_FAILURE;
}
rv = mSimpleBaseType->Resolve();
rv = mSimpleBaseType->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
}
if (mModelGroup) {
rv = mModelGroup->Resolve();
rv = mModelGroup->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString modelName;
nsresult rv1 = type->GetName(modelName);
NS_ENSURE_SUCCESS(rv1, rv1);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema complex type, ");
errorMsg.AppendLiteral("cannot resolve model group \"");
errorMsg.Append(modelName);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return NS_ERROR_FAILURE;
}
}
@ -128,18 +163,18 @@ nsSchemaComplexType::Resolve()
PRUint16 schemaType;
placeHolder->GetSchemaType(&schemaType);
if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
rv = mSchema->ResolveTypePlaceholder(placeHolder, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, placeHolder, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
rv = type->Resolve();
rv = type->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
SetArrayInfo(type, mArrayInfo->GetDimension());
}
else {
rv = placeHolder->Resolve();
rv = placeHolder->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -39,6 +39,7 @@
#ifndef __nsSchemaLoader_h__
#define __nsSchemaLoader_h__
#include "nsIWebServiceErrorHandler.h"
#include "nsISchemaLoader.h"
#include "nsSchemaPrivate.h"
#include "nsDOMUtils.h"
@ -102,73 +103,90 @@ public:
NS_DECL_NSISCHEMACOLLECTION
protected:
nsresult ProcessElement(nsSchema* aSchema,
nsresult ProcessElement(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsISchemaElement** aSchemaElement);
nsresult ProcessComplexType(nsSchema* aSchema,
nsresult ProcessComplexType(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsISchemaComplexType** aComplexType);
nsresult ProcessComplexTypeBody(nsSchema* aSchema,
nsresult ProcessComplexTypeBody(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
nsSchemaModelGroup* aSequence,
PRUint16* aContentModel);
nsresult ProcessSimpleContent(nsSchema* aSchema,
nsresult ProcessSimpleContent(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
PRUint16* aDerivation,
nsISchemaType** aBaseType);
nsresult ProcessSimpleContentRestriction(nsSchema* aSchema,
nsresult ProcessSimpleContentRestriction(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
nsISchemaType* aBaseType,
nsISchemaSimpleType** aSimpleBaseType);
nsresult ProcessSimpleContentExtension(nsSchema* aSchema,
nsresult ProcessSimpleContentExtension(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
nsISchemaType* aBaseType,
nsISchemaSimpleType** aSimpleBaseType);
nsresult ProcessComplexContent(nsSchema* aSchema,
nsresult ProcessComplexContent(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
PRUint16* aContentModel,
PRUint16* aDerivation,
nsISchemaType** aBaseType);
nsresult ProcessSimpleType(nsSchema* aSchema,
nsresult ProcessSimpleType(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeRestriction(nsSchema* aSchema,
nsresult ProcessSimpleTypeRestriction(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
const nsAString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeList(nsSchema* aSchema,
nsresult ProcessSimpleTypeList(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
const nsAString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeUnion(nsSchema* aSchema,
nsresult ProcessSimpleTypeUnion(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
const nsAString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessAttribute(nsSchema* aSchema,
nsresult ProcessAttribute(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsISchemaAttribute** aAttribute);
nsresult ProcessAttributeGroup(nsSchema* aSchema,
nsresult ProcessAttributeGroup(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsISchemaAttributeGroup** aAttributeGroup);
nsresult ProcessAttributeComponent(nsSchema* aSchema,
nsresult ProcessAttributeComponent(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaAttributeComponent** aAttribute);
nsresult ProcessModelGroup(nsSchema* aSchema,
nsresult ProcessModelGroup(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsSchemaModelGroup* aParentSequence,
nsISchemaModelGroup** aModelGroup);
nsresult ProcessParticle(nsSchema* aSchema,
nsresult ProcessParticle(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaParticle** aModelGroup);
nsresult ProcessFacet(nsSchema* aSchema,
nsresult ProcessFacet(nsIWebServiceErrorHandler* aErrorHandler,
nsSchema* aSchema,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaFacet** aFacet);

Просмотреть файл

@ -117,9 +117,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaModelGroup,
nsISchemaModelGroup)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaModelGroup::Resolve()
nsSchemaModelGroup::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -131,8 +131,20 @@ nsSchemaModelGroup::Resolve()
count = mParticles.Count();
for (i = 0; i < count; ++i) {
rv = mParticles.ObjectAt(i)->Resolve();
rv = mParticles.ObjectAt(i)->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
nsAutoString name;
nsresult rc = mParticles.ObjectAt(i)->GetName(name);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure resolving schema particle, cannot ");
errorMsg.AppendLiteral("resolve particle \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
@ -288,9 +300,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaModelGroupRef,
nsISchemaParticle,
nsISchemaModelGroup)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaModelGroupRef::Resolve()
nsSchemaModelGroupRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
nsresult rv = NS_OK;
@ -304,7 +316,7 @@ nsSchemaModelGroupRef::Resolve()
}
if (mModelGroup) {
rv = mModelGroup->Resolve();
rv = mModelGroup->Resolve(aErrorHandler);
}
return rv;
@ -420,9 +432,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaAnyParticle,
nsISchemaAnyParticle)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaAnyParticle::Resolve()
nsSchemaAnyParticle::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}
@ -508,9 +520,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaElement,
nsISchemaParticle,
nsISchemaElement)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaElement::Resolve()
nsSchemaElement::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -520,13 +532,13 @@ nsSchemaElement::Resolve()
nsresult rv = NS_OK;
if (mType && mSchema) {
nsCOMPtr<nsISchemaType> type;
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mType, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return rv;
}
mType = type;
rv = mType->Resolve();
rv = mType->Resolve(aErrorHandler);
}
return rv;
@ -675,9 +687,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaElementRef,
nsISchemaParticle,
nsISchemaElement)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaElementRef::Resolve()
nsSchemaElementRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
nsresult rv = NS_OK;
if (mIsResolved) {
@ -690,7 +702,7 @@ nsSchemaElementRef::Resolve()
}
if (mElement) {
rv = mElement->Resolve();
rv = mElement->Resolve(aErrorHandler);
}
return rv;

Просмотреть файл

@ -39,6 +39,7 @@
#ifndef __nsSchemaPrivate_h__
#define __nsSchemaPrivate_h__
#include "nsIWebServiceErrorHandler.h"
#include "nsISchema.h"
// XPCOM Includes
@ -57,6 +58,17 @@
#define NS_SOAP_1_2_ENCODING_NAMESPACE \
"http://www.w3.org/2001/09/soap-encoding"
/**
* Fire error on error handler passed as argument, only to be used
* in ProcessXXX or Resolve methods.
*/
#define NS_SCHEMALOADER_FIRE_ERROR(status,statusMessage) \
PR_BEGIN_MACRO \
if (aErrorHandler) { \
aErrorHandler->OnError(status, statusMessage); \
} \
PR_END_MACRO
class nsSchema : public nsISchema
{
public:
@ -75,7 +87,8 @@ public:
NS_IMETHOD AddAttributeGroup(nsISchemaAttributeGroup* aAttributeGroup);
NS_IMETHOD AddModelGroup(nsISchemaModelGroup* aModelGroup);
void DropCollectionReference();
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsresult ResolveTypePlaceholder(nsIWebServiceErrorHandler* aErrorHandler,
nsISchemaType* aPlaceholder,
nsISchemaType** aType);
PRBool IsElementFormQualified() { return mElementFormQualified; }
@ -114,7 +127,7 @@ protected:
NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace) { \
return nsSchemaComponentBase::GetTargetNamespace(aTargetNamespace); \
} \
NS_IMETHOD Resolve(); \
NS_IMETHOD Resolve(nsIWebServiceErrorHandler* aErrorHandler); \
NS_IMETHOD Clear();
class nsSchemaBuiltinType : public nsISchemaBuiltinType
@ -372,7 +385,7 @@ public:
NS_DECL_NSISCHEMAELEMENT
NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace);
NS_IMETHOD Resolve();
NS_IMETHOD Resolve(nsIWebServiceErrorHandler* aErrorHandler);
NS_IMETHOD Clear();
NS_IMETHOD SetType(nsISchemaType* aType);
NS_IMETHOD SetConstraints(const nsAString& aDefaultValue,

Просмотреть файл

@ -67,16 +67,15 @@ nsSchemaBuiltinType::GetTargetNamespace(nsAString& aTargetNamespace)
return NS_OK;
}
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaBuiltinType::Resolve()
nsSchemaBuiltinType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}
/* void clear (); */
NS_IMETHODIMP
nsSchemaBuiltinType::Clear()
NS_IMETHODIMP nsSchemaBuiltinType::Clear()
{
return NS_OK;
}
@ -283,9 +282,9 @@ NS_IMPL_ISUPPORTS4_CI(nsSchemaListType,
nsISchemaSimpleType,
nsISchemaListType)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaListType::Resolve()
nsSchemaListType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -295,7 +294,7 @@ nsSchemaListType::Resolve()
mIsResolved = PR_TRUE;
if (mListType && mSchema) {
nsCOMPtr<nsISchemaType> type;
rv = mSchema->ResolveTypePlaceholder(mListType, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mListType, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
@ -304,7 +303,7 @@ nsSchemaListType::Resolve()
return NS_ERROR_FAILURE;
}
}
rv = mListType->Resolve();
rv = mListType->Resolve(aErrorHandler);
return rv;
}
@ -397,9 +396,9 @@ NS_IMPL_ISUPPORTS4_CI(nsSchemaUnionType,
nsISchemaSimpleType,
nsISchemaUnionType)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaUnionType::Resolve()
nsSchemaUnionType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -411,14 +410,14 @@ nsSchemaUnionType::Resolve()
count = mUnionTypes.Count();
for (i = 0; i < count; ++i) {
nsCOMPtr<nsISchemaType> type;
nsresult rv = mSchema->ResolveTypePlaceholder(mUnionTypes.ObjectAt(i),
nsresult rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mUnionTypes.ObjectAt(i),
getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsISchemaSimpleType> simpleType = do_QueryInterface(type);
mUnionTypes.ReplaceObjectAt(simpleType, i);
rv = type->Resolve();
rv = type->Resolve(aErrorHandler);
if (NS_FAILED(rv)) {
return rv;
}
@ -533,9 +532,9 @@ NS_IMPL_ISUPPORTS4_CI(nsSchemaRestrictionType,
nsISchemaSimpleType,
nsISchemaRestrictionType)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaRestrictionType::Resolve()
nsSchemaRestrictionType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
if (mIsResolved) {
return NS_OK;
@ -545,7 +544,7 @@ nsSchemaRestrictionType::Resolve()
mIsResolved = PR_TRUE;
if (mBaseType && mSchema) {
nsCOMPtr<nsISchemaType> type;
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(type));
rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mBaseType, getter_AddRefs(type));
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
@ -553,7 +552,7 @@ nsSchemaRestrictionType::Resolve()
if (!mBaseType) {
return NS_ERROR_FAILURE;
}
rv = mBaseType->Resolve();
rv = mBaseType->Resolve(aErrorHandler);
}
return rv;
@ -690,9 +689,9 @@ NS_IMPL_ISUPPORTS3_CI(nsSchemaTypePlaceholder,
nsISchemaSimpleType)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaTypePlaceholder::Resolve()
nsSchemaTypePlaceholder::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}
@ -750,9 +749,9 @@ NS_IMPL_ISUPPORTS2_CI(nsSchemaFacet,
nsISchemaComponent,
nsISchemaFacet)
/* void resolve (); */
/* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
NS_IMETHODIMP
nsSchemaFacet::Resolve()
nsSchemaFacet::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
{
return NS_OK;
}

Просмотреть файл

@ -36,6 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIWebServiceErrorHandler.h"
#include "nsWSDLLoader.h"
// loading includes
@ -240,6 +242,13 @@ nsWSDLLoadRequest::nsWSDLLoadRequest(PRBool aIsSync,
const nsAString& aPortName)
: mListener(aListener), mIsSync(aIsSync), mPortName(aPortName)
{
mErrorHandler = mListener;
if (!mErrorHandler) {
NS_WARNING("nsWSDLLoadRequest::<init>: Error about interface "
"nsIWebserviceErrorHandler");
}
}
nsWSDLLoadRequest::~nsWSDLLoadRequest()
@ -316,6 +325,10 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_FAILED(rv)) {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure retrieving XML "));
errorMsg.AppendLiteral("response for WSDL");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
@ -327,6 +340,17 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
NS_LITERAL_STRING(NS_WSDL_NAMESPACE))) {
rv = PushContext(document, aURI);
if (NS_FAILED(rv)) {
nsAutoString elementName;
nsresult rc = element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure queuing element \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\" to be processed");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
@ -335,6 +359,17 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
PopContext();
if (NS_FAILED(rv)) {
nsAutoString elementName;
nsresult rc = element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL element \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
@ -343,7 +378,7 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
IsElementOfNamespace(element,
NS_LITERAL_STRING(SCHEMA_1999_NAMESPACE))) {
nsCOMPtr<nsISchema> schema;
rv = mSchemaLoader->ProcessSchemaElement(element,
rv = mSchemaLoader->ProcessSchemaElement(mErrorHandler, element,
getter_AddRefs(schema));
if (NS_FAILED(rv)) {
return NS_ERROR_WSDL_SCHEMA_PROCESSING_ERROR;
@ -356,10 +391,27 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
mTypes.Put(&key, schema);
}
else {
rv = NS_ERROR_WSDL_NOT_WSDL_ELEMENT; // element of unknown namespace
// element of unknown namespace
rv = NS_ERROR_WSDL_NOT_WSDL_ELEMENT;
nsAutoString elementName;
nsresult rc = element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rc, rc);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, element of ");
errorMsg.AppendLiteral("unknown namespace \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
else {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure processing WSDL, no document"));
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_NOT_WSDL_ELEMENT, errorMsg);
return NS_ERROR_WSDL_NOT_WSDL_ELEMENT;
}
}
@ -421,6 +473,37 @@ nsWSDLLoadRequest::HandleEvent(nsIDOMEvent *event)
if (NS_SUCCEEDED(rv)) {
rv = ContineProcessingTillDone();
if (NS_FAILED(rv)) {
nsAutoString elementName;
element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL element \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_LOADING_ERROR, errorMsg);
return NS_ERROR_WSDL_LOADING_ERROR;
}
}
else {
nsAutoString elementName;
element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure queuing WSDL element \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\" for processing");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_LOADING_ERROR, errorMsg);
return NS_ERROR_WSDL_LOADING_ERROR;
}
}
else if (IsElementOfNamespace(element,
@ -428,7 +511,7 @@ nsWSDLLoadRequest::HandleEvent(nsIDOMEvent *event)
IsElementOfNamespace(element,
NS_LITERAL_STRING(SCHEMA_1999_NAMESPACE))) {
nsCOMPtr<nsISchema> schema;
rv = mSchemaLoader->ProcessSchemaElement(element,
rv = mSchemaLoader->ProcessSchemaElement(mErrorHandler, element,
getter_AddRefs(schema));
if (NS_FAILED(rv)) {
return NS_ERROR_WSDL_SCHEMA_PROCESSING_ERROR;
@ -443,22 +526,42 @@ nsWSDLLoadRequest::HandleEvent(nsIDOMEvent *event)
rv = ContineProcessingTillDone();
}
else {
rv = NS_ERROR_WSDL_NOT_WSDL_ELEMENT; // element of unknown namespace
// element of unknown namespace
nsAutoString elementName;
rv = element->GetTagName(elementName);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_ERROR_WSDL_NOT_WSDL_ELEMENT;
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, ");
errorMsg.AppendLiteral("element of unknown namespace \"");
errorMsg.Append(elementName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
else {
rv = NS_ERROR_WSDL_NOT_WSDL_ELEMENT;
nsAutoString errorMsg(NS_LITERAL_STRING("Failure processing WSDL document"));
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
if (NS_FAILED(rv)) {
mListener->OnError(rv, NS_LITERAL_STRING("Failure processing WSDL document"));
return NS_OK;
}
}
else if (eventType.EqualsLiteral("error")) {
mListener->OnError(NS_ERROR_WSDL_LOADING_ERROR,
NS_LITERAL_STRING("Failure loading"));
nsAutoString errorMsg(NS_LITERAL_STRING("Failure loading WSDL document"));
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_LOADING_ERROR, errorMsg);
return NS_OK;
}
@ -467,8 +570,8 @@ nsWSDLLoadRequest::HandleEvent(nsIDOMEvent *event)
mListener->OnLoad(mPort);
}
else {
mListener->OnError(NS_ERROR_WSDL_BINDING_NOT_FOUND,
NS_LITERAL_STRING("Binding not found"));
nsAutoString errorMsg(NS_LITERAL_STRING("WSDL Binding not found"));
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_BINDING_NOT_FOUND, errorMsg);
}
mRequest = nsnull;
}
@ -621,12 +724,25 @@ nsWSDLLoadRequest::GetSchemaElement(const nsAString& aName,
nsCOMPtr<nsISupports> sup = dont_AddRef(mTypes.Get(&key));
nsCOMPtr<nsISchema> schema(do_QueryInterface(sup));
if (!schema) {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure processing WSDL, "));
errorMsg.AppendLiteral("element is not schema");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT;
}
nsCOMPtr<nsISchemaElement> element;
schema->GetElementByName(aName, getter_AddRefs(element));
if (!element) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, unknown schema component \"");
errorMsg.Append(aNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(aName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT;
}
@ -651,12 +767,24 @@ nsWSDLLoadRequest::GetSchemaType(const nsAString& aName,
nsCOMPtr<nsISupports> sup = dont_AddRef(mTypes.Get(&key));
nsCOMPtr<nsISchema> schema(do_QueryInterface(sup));
if (!schema) {
nsAutoString errorMsg(NS_LITERAL_STRING("Failure processing WSDL, not schema"));
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT;
}
nsCOMPtr<nsISchemaType> type;
schema->GetTypeByName(aName, getter_AddRefs(type));
if (!type) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, unknown schema type \"");
errorMsg.Append(aNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(aName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_SCHEMA_COMPONENT;
}
@ -679,6 +807,15 @@ nsWSDLLoadRequest::GetMessage(const nsAString& aName,
nsCOMPtr<nsISupports> sup = dont_AddRef(mMessages.Get(&key));
nsCOMPtr<nsIWSDLMessage> message(do_QueryInterface(sup));
if (!message) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, unknown WSDL component \"");
errorMsg.Append(aNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(aName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT;
}
@ -701,6 +838,15 @@ nsWSDLLoadRequest::GetPortType(const nsAString& aName,
nsCOMPtr<nsISupports> sup = dont_AddRef(mPortTypes.Get(&key));
nsCOMPtr<nsIWSDLPort> port(do_QueryInterface(sup));
if (!port) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, unknown WSDL port type \"");
errorMsg.Append(aNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(aName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT;
}
@ -759,11 +905,28 @@ nsWSDLLoadRequest::ProcessImportElement(nsIDOMElement* aElement,
nsCOMPtr<nsIURI> uri, baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), documentLocation);
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, ");
errorMsg.AppendLiteral("cannot find base URI for document location \"");
errorMsg.Append(documentLocation);
errorMsg.AppendLiteral("\" for import \"");
errorMsg.Append(location);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
rv = NS_NewURI(getter_AddRefs(uri), location, nsnull, baseURI);
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, Cannot find URI for import \"");
errorMsg.Append(location);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
@ -778,6 +941,13 @@ nsWSDLLoadRequest::ProcessImportElement(nsIDOMElement* aElement,
if (equal) {
// Looks like this uri has already been loaded.
// Loading it again will end up in an infinite loop.
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, import \"");
errorMsg.Append(location);
errorMsg.AppendLiteral("\" could cause recursive import");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_RECURSIVE_IMPORT, errorMsg);
return NS_ERROR_WSDL_RECURSIVE_IMPORT;
}
}
@ -824,7 +994,7 @@ nsWSDLLoadRequest::ProcessTypesElement(nsIDOMElement* aElement)
// XXX : We need to deal with xs:import elements too.
if (tagName == nsWSDLAtoms::sSchema_atom) {
nsCOMPtr<nsISchema> schema;
rv = mSchemaLoader->ProcessSchemaElement(childElement,
rv = mSchemaLoader->ProcessSchemaElement(mErrorHandler, childElement,
getter_AddRefs(schema));
if (NS_FAILED(rv)) {
return NS_ERROR_WSDL_SCHEMA_PROCESSING_ERROR;
@ -875,6 +1045,15 @@ nsWSDLLoadRequest::ProcessAbstractPartElement(nsIDOMElement* aElement,
rv = GetSchemaElement(elementLocalName, elementNamespace,
getter_AddRefs(schemaElement));
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, cannot find schema element \"");
errorMsg.Append(elementNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(elementLocalName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
@ -893,6 +1072,15 @@ nsWSDLLoadRequest::ProcessAbstractPartElement(nsIDOMElement* aElement,
rv = GetSchemaType(typeLocalName, typeNamespace,
getter_AddRefs(schemaType));
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, cannot find schema type \"");
errorMsg.Append(typeNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(typeLocalName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
@ -983,6 +1171,15 @@ nsWSDLLoadRequest::ProcessOperationComponent(nsIDOMElement* aElement,
context->GetTargetNamespace(targetNamespace);
rv = GetMessage(messageLocalName, targetNamespace, aMessage);
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, cannot find message \"");
errorMsg.Append(targetNamespace);
errorMsg.AppendLiteral(":");
errorMsg.Append(messageLocalName);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}
@ -1238,6 +1435,13 @@ nsWSDLLoadRequest::ProcessOperationBinding(nsIDOMElement* aElement,
nsCOMPtr<nsIWSDLOperation> operation;
aPort->GetOperationByName(name, getter_AddRefs(operation));
if (!operation) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing WSDL, cannot find operation \"");
errorMsg.Append(name);
errorMsg.AppendLiteral("\"");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT, errorMsg);
return NS_ERROR_WSDL_UNKNOWN_WSDL_COMPONENT;
}
nsWSDLOperation* operationInst = NS_REINTERPRET_CAST(nsWSDLOperation*,
@ -1314,7 +1518,11 @@ nsWSDLLoadRequest::ProcessOperationBinding(nsIDOMElement* aElement,
else if ((tagName == nsWSDLAtoms::sFault_atom) &&
IsElementOfNamespace(childElement,
NS_LITERAL_STRING(NS_WSDL_NAMESPACE))) {
// XXX TO BE IMPLEMENTED
//XXX To be implemented
nsAutoString errorMsg(NS_LITERAL_STRING("Fault management not yet "));
errorMsg.AppendLiteral("implemented in WSDL support");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_NOT_IMPLEMENTED, errorMsg);
}
}
@ -1415,6 +1623,10 @@ nsWSDLLoadRequest::ProcessBindingElement(nsIDOMElement* aElement)
if (!foundSOAPBinding) {
// If we don't have a SOAP binding, we can't continue
nsAutoString errorMsg(NS_LITERAL_STRING("Failure processing WSDL, "));
errorMsg.AppendLiteral("no SOAP binding found");
NS_WSDLLOADER_FIRE_ERROR(NS_ERROR_WSDL_BINDING_NOT_FOUND, errorMsg);
return NS_ERROR_WSDL_BINDING_NOT_FOUND;
}
nsWSDLPort* portInst = NS_REINTERPRET_CAST(nsWSDLPort*, port.get());

Просмотреть файл

@ -39,6 +39,8 @@
#ifndef __nsWSDLLoader_h__
#define __nsWSDLLoader_h__
#include "nsIWebServiceErrorHandler.h"
#include "nsIWSDLLoader.h"
#include "nsWSDLPrivate.h"
@ -202,6 +204,7 @@ protected:
nsCOMPtr<nsISchemaLoader> mSchemaLoader;
nsCOMPtr<nsIWSDLPort> mPort;
nsCOMArray<nsIURI> mImportList;
nsCOMPtr<nsIWebServiceErrorHandler> mErrorHandler;
PRPackedBool mIsSync;

Просмотреть файл

@ -65,6 +65,17 @@
#define NS_WSDL_NAMESPACE "http://schemas.xmlsoap.org/wsdl/"
#define NS_WSDL_SOAP_NAMESPACE "http://schemas.xmlsoap.org/wsdl/soap/"
/**
* Fire error on error handler passed as argument, only to be used
* in ProcessXXX or Resolve methods.
*/
#define NS_WSDLLOADER_FIRE_ERROR(status,statusMessage) \
PR_BEGIN_MACRO \
if (mErrorHandler) { \
mErrorHandler->OnError(status, statusMessage); \
} \
PR_END_MACRO
class nsSOAPPortBinding : public nsISOAPPortBinding
{
public: