зеркало из https://github.com/mozilla/pjs.git
First implementation of proxy and call context, movement of variant to parameter code, interface improvements. This is not part of the default build.
This commit is contained in:
Родитель
cf56f0838b
Коммит
85b96f2659
|
@ -38,15 +38,21 @@ REQUIRES = xpcom \
|
|||
caps \
|
||||
js \
|
||||
necko \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS= \
|
||||
wspproxy.cpp \
|
||||
wspcallcontext.cpp \
|
||||
wspfactory.cpp \
|
||||
wspcomplextypewrapper.cpp \
|
||||
wsppropertybagwrapper.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../../soap/src \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
|
|
@ -0,0 +1,376 @@
|
|||
/* -*- 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 "wspprivate.h"
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsISOAPCall.h"
|
||||
#include "nsISOAPHeaderBlock.h"
|
||||
#include "nsISOAPParameter.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation)
|
||||
: mProxy(aProxy), mCall(aSOAPCall), mMethodName(aMethodName),
|
||||
mOperation(aOperation), mStatus(NS_ERROR_NOT_AVAILABLE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
WSPCallContext::~WSPCallContext()
|
||||
{
|
||||
NS_IF_RELEASE(mProxy);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3_CI(WSPCallContext,
|
||||
nsIWebServiceCallContext,
|
||||
nsIWebServiceSOAPCallContext,
|
||||
nsISOAPResponseListener)
|
||||
|
||||
/* readonly attribute nsIWebServiceProxy proxy; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetProxy(nsIWebServiceProxy * *aProxy)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProxy);
|
||||
|
||||
*aProxy = mProxy;
|
||||
NS_IF_ADDREF(*aProxy);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString methodName; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetMethodName(nsAString & aMethodName)
|
||||
{
|
||||
aMethodName.Assign(mMethodName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint32 status; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetStatus(PRUint32 *aStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStatus);
|
||||
*aStatus = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIException pendingException; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetPendingException(nsIException * *aPendingException)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPendingException);
|
||||
*aPendingException = mException;
|
||||
NS_IF_ADDREF(*aPendingException);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIWSDLOperation operation; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetOperation(nsIWSDLOperation * *aOperation)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOperation);
|
||||
*aOperation = mOperation;
|
||||
NS_IF_ADDREF(*aOperation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void abort (in nsIException error); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::Abort(nsIException *error)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mCompletion) {
|
||||
mException = error;
|
||||
PRBool ret;
|
||||
rv = mCompletion->Abort(&ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (ret) {
|
||||
rv = CallCompletionListener();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISOAPResponse soapResponse; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetSoapResponse(nsISOAPResponse * *aSoapResponse)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSoapResponse);
|
||||
if (mCompletion) {
|
||||
return mCompletion->GetResponse(aSoapResponse);
|
||||
}
|
||||
*aSoapResponse = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse,
|
||||
nsISOAPCall *aCall,
|
||||
nsresult status,
|
||||
PRBool aLast,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ASSERTION(aCall == mCall, "unexpected call instance");
|
||||
NS_ASSERTION(!aLast, "only single response expected");
|
||||
mStatus = status;
|
||||
*_retval = PR_TRUE;
|
||||
CallCompletionListener();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallAsync(PRUint32 aListenerMethodIndex,
|
||||
nsISupports* aListener)
|
||||
{
|
||||
mAsyncListener = aListener;
|
||||
mListenerMethodIndex = aListenerMethodIndex;
|
||||
return mCall->AsyncInvoke(this, getter_AddRefs(mCompletion));
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsresult rv = mCall->Invoke(getter_AddRefs(response));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallCompletionListener()
|
||||
{
|
||||
nsresult rv;
|
||||
#define PARAM_BUFFER_COUNT 8
|
||||
|
||||
nsXPTCVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCVariant* dispatchParams = nsnull;
|
||||
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
mCompletion->GetResponse(getter_AddRefs(response));
|
||||
if (response) {
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
rv = response->GetFault(getter_AddRefs(fault));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (fault) {
|
||||
WSPException* exception = new WSPException(fault, mStatus);
|
||||
if (!exception) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mException = exception;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> listenerInterfaceInfo;
|
||||
mProxy->GetListenerInterfaceInfo(getter_AddRefs(listenerInterfaceInfo));
|
||||
NS_ASSERTION(listenerInterfaceInfo, "WSPCallContext:Missing listener interface info");
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
rv = listenerInterfaceInfo->GetMethodInfo(mListenerMethodIndex,
|
||||
&methodInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRUint32 paramCount = methodInfo->GetParamCount();
|
||||
if(paramCount > PARAM_BUFFER_COUNT) {
|
||||
if(!(dispatchParams = new nsXPTCVariant[paramCount])) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dispatchParams = paramBuffer;
|
||||
}
|
||||
|
||||
// iterate through the params to clear flags
|
||||
PRUint32 i;
|
||||
for(i = 0; i < paramCount; i++) {
|
||||
nsXPTCVariant* dp = &dispatchParams[i];
|
||||
dp->ClearFlags();
|
||||
dp->val.p = nsnull;
|
||||
}
|
||||
|
||||
PRUint32 headerCount, bodyCount;
|
||||
nsISOAPHeaderBlock** headerBlocks;
|
||||
nsISOAPParameter** bodyBlocks;
|
||||
|
||||
// If we have an exception, report it now
|
||||
if (mException) {
|
||||
dispatchParams[0].val.p = NS_STATIC_CAST(void*, mException);
|
||||
dispatchParams[0].SetValIsInterface();
|
||||
|
||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
paramCount, dispatchParams);
|
||||
}
|
||||
else if (response) {
|
||||
nsCOMPtr<nsIWSDLBinding> binding;
|
||||
rv = mOperation->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
PRUint16 style;
|
||||
operationBinding->GetStyle(&style);
|
||||
|
||||
rv = response->GetHeaderBlocks(&headerCount, &headerBlocks);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
rv = response->GetParameters(style == nsISOAPPortBinding::STYLE_DOCUMENT,
|
||||
&bodyCount, &bodyBlocks);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWSDLMessage> output;
|
||||
rv = mOperation->GetOutput(getter_AddRefs(output));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
PRUint32 partCount;
|
||||
output->GetPartCount(&partCount);
|
||||
|
||||
PRUint32 bodyEntry = 0, headerEntry = 0, arrayOffset = 0;
|
||||
for (i = 0; i < partCount; i++) {
|
||||
nsCOMPtr<nsIWSDLPart> part;
|
||||
rv = output->GetPart(i, getter_AddRefs(part));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
rv = part->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
PRUint16 location;
|
||||
partBinding->GetLocation(&location);
|
||||
|
||||
nsCOMPtr<nsISOAPBlock> block;
|
||||
if (location == nsISOAPPartBinding::LOCATION_HEADER) {
|
||||
block = do_QueryInterface(headerBlocks[headerEntry++]);
|
||||
}
|
||||
else if (location == nsISOAPPartBinding::LOCATION_BODY) {
|
||||
block = do_QueryInterface(bodyBlocks[bodyEntry++]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISchemaComponent> schemaComponent;
|
||||
rv = part->GetSchemaComponent(getter_AddRefs(schemaComponent));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
nsCOMPtr<nsISchemaElement> element = do_QueryInterface(schemaComponent);
|
||||
if (!element) {
|
||||
rv = element->GetType(getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = do_QueryInterface(schemaComponent);
|
||||
}
|
||||
|
||||
rv = block->SetSchemaType(type);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIVariant> value;
|
||||
rv = block->GetValue(getter_AddRefs(value));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsXPTCVariant* vars = dispatchParams+i+1+arrayOffset;
|
||||
if (WSPProxy::IsArray(part)) {
|
||||
arrayOffset++;
|
||||
}
|
||||
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(i+1+arrayOffset);
|
||||
rv = WSPProxy::VariantToInParameter(listenerInterfaceInfo,
|
||||
mListenerMethodIndex,
|
||||
¶mInfo,
|
||||
value, vars);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
|
||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
paramCount, dispatchParams);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
call_completion_end:
|
||||
if (headerCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(headerCount, headerBlocks);
|
||||
}
|
||||
if (bodyCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
if(dispatchParams && dispatchParams != paramBuffer) {
|
||||
delete [] dispatchParams;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -147,7 +147,7 @@ WSPComplexTypeEnumerator::GetNext(nsISupports **_retval)
|
|||
}
|
||||
|
||||
nsAutoString propName;
|
||||
rv = WSPFactory::MethodToPropertyName(nsDependentCString(methodInfo->GetName()), propName);
|
||||
rv = WSPFactory::C2XML(nsDependentCString(methodInfo->GetName()), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -211,172 +211,6 @@ WSPComplexTypeWrapper::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::ResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance(NS_VARIANT_CONTRACTID,
|
||||
&rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
var->SetAsInt8(aResult.val.i8);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
var->SetAsInt16(aResult.val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
var->SetAsInt32(aResult.val.i32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
var->SetAsInt64(aResult.val.i64);
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
var->SetAsUint8(aResult.val.u8);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
var->SetAsUint16(aResult.val.u16);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
var->SetAsUint32(aResult.val.u32);
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
var->SetAsUint64(aResult.val.u64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
var->SetAsFloat(aResult.val.f);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
var->SetAsDouble(aResult.val.d);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
var->SetAsBool(aResult.val.b);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
var->SetAsChar(aResult.val.c);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
var->SetAsWChar(aResult.val.wc);
|
||||
break;
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
var->SetAsAString(*((nsAString*)aResult.val.p));
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
{
|
||||
nsISupports* instance = (nsISupports*)aResult.val.p;
|
||||
if (instance) {
|
||||
// Rewrap an interface instance in a property bag
|
||||
nsCOMPtr<WSPComplexTypeWrapper> wrapper;
|
||||
rv = Create(instance, aInterfaceInfo,
|
||||
getter_AddRefs(wrapper));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
var->SetAsInterface(NS_GET_IID(nsIPropertyBag), wrapper);
|
||||
NS_RELEASE(instance);
|
||||
}
|
||||
else {
|
||||
var->SetAsEmpty();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_ERROR("Bad attribute type for complex type interface");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aVariant = var;
|
||||
NS_ADDREF(*aVariant);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::ArrayResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> retvar = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (aLength) {
|
||||
nsIVariant** entries = (nsIVariant**)nsMemory::Alloc(aLength * sizeof(nsIVariant*));
|
||||
if (!entries) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRUint32 i = 0;
|
||||
nsXPTCVariant var;
|
||||
void* array = aResult.val.p;
|
||||
nsCOMPtr<nsIVariant> element;
|
||||
|
||||
#define POPULATE(_t,_v) \
|
||||
PR_BEGIN_MACRO \
|
||||
for(i = 0; i < aLength; i++) \
|
||||
{ \
|
||||
var.type = aTypeTag; \
|
||||
var.val._v = *((_t*)array + i); \
|
||||
rv = ResultAsVariant(aTypeTag, var, aInterfaceInfo, \
|
||||
entries+i); \
|
||||
if (NS_FAILED(rv)) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8: POPULATE(PRInt8, i8); break;
|
||||
case nsXPTType::T_I16: POPULATE(PRInt16, i16); break;
|
||||
case nsXPTType::T_I32: POPULATE(PRInt32, i32); break;
|
||||
case nsXPTType::T_I64: POPULATE(PRInt64, i64); break;
|
||||
case nsXPTType::T_U8: POPULATE(PRUint8, u8); break;
|
||||
case nsXPTType::T_U16: POPULATE(PRUint16, u16); break;
|
||||
case nsXPTType::T_U32: POPULATE(PRUint32, u32); break;
|
||||
case nsXPTType::T_U64: POPULATE(PRUint64, u64); break;
|
||||
case nsXPTType::T_FLOAT: POPULATE(float, f); break;
|
||||
case nsXPTType::T_DOUBLE: POPULATE(double, d); break;
|
||||
case nsXPTType::T_BOOL: POPULATE(PRBool, b); break;
|
||||
case nsXPTType::T_CHAR: POPULATE(char, c); break;
|
||||
case nsXPTType::T_WCHAR: POPULATE(PRUnichar, wc); break;
|
||||
case nsXPTType::T_INTERFACE: POPULATE(nsISupports*, p); break;
|
||||
}
|
||||
|
||||
#undef POPULATE
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = retvar->SetAsArray(nsIDataType::TYPE_INTERFACE, aLength, entries);
|
||||
}
|
||||
|
||||
// Even if we failed while converting, we want to release
|
||||
// the entries that were already created.
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, entries);
|
||||
}
|
||||
else {
|
||||
retvar->SetAsEmpty();
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aVariant = retvar;
|
||||
NS_ADDREF(*aVariant);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* nsIVariant getProperty (in AString name); */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeWrapper::GetProperty(const nsAString & name,
|
||||
|
@ -385,7 +219,7 @@ WSPComplexTypeWrapper::GetProperty(const nsAString & name,
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsCAutoString methodName;
|
||||
WSPFactory::PropertyToMethodName(name, methodName);
|
||||
WSPFactory::XML2C(name, methodName);
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
PRUint16 methodIndex;
|
||||
|
@ -508,11 +342,12 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
|||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_ARRAY) {
|
||||
rv = ArrayResultAsVariant(arrayType.TagPart(), var[1],
|
||||
var[0].val.u32, iinfo, _retval);
|
||||
rv = WSPProxy::ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), var[1],
|
||||
var[0].val.u32, iinfo,
|
||||
_retval);
|
||||
}
|
||||
else {
|
||||
rv = ResultAsVariant(type_tag, var[0], iinfo, _retval);
|
||||
rv = WSPProxy::XPTCMiniVariantToVariant(type_tag, var[0], iinfo, _retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -80,14 +80,14 @@ WSPFactory::CreateProxyAsync(const nsAString & wsdlURL,
|
|||
#define P2M_ESCAPE_CHARACTER '_'
|
||||
|
||||
nsresult
|
||||
WSPFactory::MethodToPropertyName(const nsAReadableCString& aMethodName,
|
||||
nsAWritableString& aPropertyName)
|
||||
WSPFactory::C2XML(const nsAReadableCString& aCIdentifier,
|
||||
nsAWritableString& aXMLIdentifier)
|
||||
{
|
||||
nsReadingIterator<char> current, end;
|
||||
|
||||
aPropertyName.Truncate();
|
||||
aMethodName.BeginReading(current);
|
||||
aMethodName.EndReading(end);
|
||||
aXMLIdentifier.Truncate();
|
||||
aCIdentifier.BeginReading(current);
|
||||
aCIdentifier.EndReading(end);
|
||||
|
||||
while (current != end) {
|
||||
char ch = *current++;
|
||||
|
@ -111,21 +111,21 @@ WSPFactory::MethodToPropertyName(const nsAReadableCString& aMethodName,
|
|||
else {
|
||||
uch = PRUnichar(ch);
|
||||
}
|
||||
aPropertyName.Append(uch);
|
||||
aXMLIdentifier.Append(uch);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
WSPFactory::PropertyToMethodName(const nsAReadableString& aPropertyName,
|
||||
nsAWritableCString& aMethodName)
|
||||
WSPFactory::XML2C(const nsAReadableString& aXMLIndentifier,
|
||||
nsAWritableCString& aCIdentifier)
|
||||
{
|
||||
nsReadingIterator<PRUnichar> current, end;
|
||||
|
||||
aMethodName.Truncate();
|
||||
aPropertyName.BeginReading(current);
|
||||
aPropertyName.EndReading(end);
|
||||
aCIdentifier.Truncate();
|
||||
aXMLIndentifier.BeginReading(current);
|
||||
aXMLIndentifier.EndReading(end);
|
||||
|
||||
while (current != end) {
|
||||
PRUnichar uch = *current++;
|
||||
|
@ -133,14 +133,14 @@ WSPFactory::PropertyToMethodName(const nsAReadableString& aPropertyName,
|
|||
((PRUnichar('A') <= uch) && (uch <= PRUnichar('Z'))) ||
|
||||
((PRUnichar('0') <= uch) && (uch <= PRUnichar('9')))) {
|
||||
// Casting is safe since we know that it's an ASCII character
|
||||
aMethodName.Append(char(uch));
|
||||
aCIdentifier.Append(char(uch));
|
||||
}
|
||||
else {
|
||||
// Escape the character and append to the string
|
||||
char buf[6];
|
||||
buf[0] = P2M_ESCAPE_CHARACTER;
|
||||
PR_snprintf(buf+1, 5, "%hx", uch);
|
||||
aMethodName.Append(buf, 5);
|
||||
aCIdentifier.Append(buf, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,13 @@
|
|||
#include "nsIWebServiceProxy.h"
|
||||
#include "nsIWSDL.h"
|
||||
|
||||
// SOAP includes
|
||||
#include "nsISOAPCall.h"
|
||||
#include "nsISOAPResponse.h"
|
||||
#include "nsISOAPResponseListener.h"
|
||||
#include "nsISOAPCallCompletion.h"
|
||||
#include "nsISOAPFault.h"
|
||||
|
||||
// interface info includes
|
||||
#include "xptcall.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
@ -52,10 +59,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsIPropertyBag.h"
|
||||
|
||||
class nsISOAPCall;
|
||||
class nsISOAPResponse;
|
||||
class nsISOAPParameter;
|
||||
#include "nsIException.h"
|
||||
|
||||
class WSPFactory : public nsIWebServiceProxyFactory
|
||||
{
|
||||
|
@ -66,10 +70,10 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICEPROXYFACTORY
|
||||
|
||||
static nsresult MethodToPropertyName(const nsAReadableCString& aMethodName,
|
||||
nsAWritableString& aPropertyName);
|
||||
static void PropertyToMethodName(const nsAReadableString& aPropertyName,
|
||||
nsAWritableCString& aMethodName);
|
||||
static nsresult C2XML(const nsAReadableCString& aCIdentifier,
|
||||
nsAWritableString& aXMLIdentifier);
|
||||
static void XML2C(const nsAReadableString& aXMLIndentifier,
|
||||
nsAWritableCString& aCIdentifier);
|
||||
};
|
||||
|
||||
class WSPProxy : public nsXPTCStubBase,
|
||||
|
@ -89,41 +93,113 @@ public:
|
|||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
|
||||
nsresult Init(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
const nsAReadableString& aQualifier,
|
||||
PRBool aIsAsync);
|
||||
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
||||
|
||||
static nsresult Create(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
const nsAReadableString& aNamespace,
|
||||
const nsAReadableString& aQualifier,
|
||||
PRBool aIsAsync, WSPProxy** aProxy);
|
||||
|
||||
static nsresult XPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aIfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
|
||||
static nsresult VariantToValue(uint8 aTypeTag,
|
||||
void* aValue,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
static nsresult VariantToArrayValue(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
|
||||
static nsresult ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsXPTCMiniVariant aMiniVariant,
|
||||
PRUint32 aArrayLength,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult VariantToInParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCVariant* aXPTCVariant);
|
||||
static nsresult VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCMiniVariant* aMiniVariant);
|
||||
static PRBool IsArray(nsIWSDLPart* aPart);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWSDLPort> mPort;
|
||||
nsCOMPtr<nsIInterfaceInfo> mPrimaryInterface;
|
||||
nsString mNamespace;
|
||||
nsString mQualifier;
|
||||
PRBool mIsAsync;
|
||||
nsSupportsArray mPendingCalls;
|
||||
const nsIID* mIID;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
nsCOMPtr<nsIInterfaceInfo> mListenerInterfaceInfo;
|
||||
};
|
||||
|
||||
class WSPCallContext : public nsIWebServiceCallContext
|
||||
// public nsISOAPResponseListener
|
||||
class WSPCallContext : public nsIWebServiceSOAPCallContext,
|
||||
public nsISOAPResponseListener
|
||||
{
|
||||
public:
|
||||
WSPCallContext();
|
||||
WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation);
|
||||
virtual ~WSPCallContext();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICECALLCONTEXT
|
||||
|
||||
static nsresult Create(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation,
|
||||
WSPCallContext** aCallContext);
|
||||
NS_DECL_NSIWEBSERVICESOAPCALLCONTEXT
|
||||
NS_DECL_NSISOAPRESPONSELISTENER
|
||||
|
||||
nsresult CallAsync(PRUint32 aListenerMethodIndex,
|
||||
nsISupports* aListener);
|
||||
nsresult CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<WSPProxy> mProxy;
|
||||
// nsCOMPtr<nsISOAPCall> mSOAPCall;
|
||||
nsresult CallCompletionListener();
|
||||
|
||||
protected:
|
||||
WSPProxy* mProxy;
|
||||
nsCOMPtr<nsISOAPCall> mCall;
|
||||
nsString mMethodName;
|
||||
nsCOMPtr<nsIWSDLOperation> mOperation;
|
||||
nsCOMPtr<nsISOAPCallCompletion> mCompletion;
|
||||
nsresult mStatus;
|
||||
nsCOMPtr<nsIException> mException;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
PRUint32 mListenerMethodIndex;
|
||||
};
|
||||
|
||||
class WSPException : public nsIException
|
||||
{
|
||||
public:
|
||||
WSPException(nsISOAPFault* aFault, nsresult aStatus);
|
||||
virtual ~WSPException();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXCEPTION
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISOAPFault> mFault;
|
||||
nsresult mStatus;
|
||||
};
|
||||
|
||||
class WSPComplexTypeWrapper : public nsIPropertyBag
|
||||
|
@ -144,16 +220,6 @@ public:
|
|||
const nsXPTMethodInfo* aMethodInfo,
|
||||
nsIVariant** _retval);
|
||||
|
||||
protected:
|
||||
nsresult ResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
nsresult ArrayResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mComplexTypeInstance;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
|
@ -177,16 +243,6 @@ public:
|
|||
static nsresult Create(nsIPropertyBag* aPropertyBag,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
WSPPropertyBagWrapper** aWrapper);
|
||||
protected:
|
||||
nsresult VariantToResult(uint8 aTypeTag,
|
||||
void* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
nsresult VariantToArrayResult(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIPropertyBag> mPropertyBag;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
|
|
|
@ -89,194 +89,6 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPPropertyBagWrapper::VariantToResult(uint8 aTypeTag,
|
||||
void* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
switch(aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
rv = aProperty->GetAsInt8((PRUint8*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
rv = aProperty->GetAsInt16((PRInt16*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
rv = aProperty->GetAsInt32((PRInt32*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
rv = aProperty->GetAsInt64((PRInt64*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
rv = aProperty->GetAsUint8((PRUint8*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
rv = aProperty->GetAsUint16((PRUint16*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
rv = aProperty->GetAsUint32((PRUint32*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
rv = aProperty->GetAsUint64((PRUint64*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
rv = aProperty->GetAsFloat((float*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
rv = aProperty->GetAsDouble((double*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
rv = aProperty->GetAsBool((PRBool*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
rv = aProperty->GetAsChar((char*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
rv = aProperty->GetAsWChar((PRUnichar*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
rv = aProperty->GetAsAString(*(nsAString*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
{
|
||||
PRUint16 dataType;
|
||||
aProperty->GetDataType(&dataType);
|
||||
if (dataType == nsIDataType::TYPE_EMPTY) {
|
||||
*(nsISupports**)aResult = nsnull;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
rv = aProperty->GetAsISupports(getter_AddRefs(sup));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(sup, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
WSPPropertyBagWrapper* wrapper;
|
||||
rv = Create(propBag, aInterfaceInfo, &wrapper);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
const nsIID* iid;
|
||||
aInterfaceInfo->GetIIDShared(&iid);
|
||||
rv = wrapper->QueryInterface(*iid, (void**)aResult);
|
||||
NS_RELEASE(wrapper);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_ERROR("Bad attribute type for complex type interface");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPPropertyBagWrapper::VariantToArrayResult(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
void* array;
|
||||
PRUint16 type;
|
||||
PRUint32 count;
|
||||
|
||||
nsresult rv = aProperty->GetAsArray(&type, &count, &array);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We assume it's an array of variants.
|
||||
// XXX need a way to confirm that
|
||||
if (type != nsIDataType::TYPE_INTERFACE) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsIVariant** variants = (nsIVariant**)array;
|
||||
|
||||
PRUint32 size;
|
||||
// Allocate the array
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
case nsXPTType::T_U8:
|
||||
size = sizeof(PRUint8);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
case nsXPTType::T_U16:
|
||||
size = sizeof(PRUint16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
case nsXPTType::T_U32:
|
||||
size = sizeof(PRUint32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
case nsXPTType::T_U64:
|
||||
size = sizeof(PRUint64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
size = sizeof(float);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
size = sizeof(double);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
size = sizeof(PRBool);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
size = sizeof(char);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
size = sizeof(PRUnichar);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
size = sizeof(nsISupports*);
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unexpected array type");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void* outptr = nsMemory::Alloc(count * size);
|
||||
if (!outptr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
rv = VariantToResult(aTypeTag, (void*)((char*)outptr + (i*size)),
|
||||
aInterfaceInfo, variants[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free the variant array passed back to us
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, variants);
|
||||
|
||||
// If conversion failed, free the allocated structures
|
||||
if (NS_FAILED(rv)) {
|
||||
if (aTypeTag == nsXPTType::T_INTERFACE) {
|
||||
nsMemory::Free(outptr);
|
||||
}
|
||||
else {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, (nsISupports**)outptr);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
*((PRUint32*)aResult[0].val.p) = count;
|
||||
*((void**)aResult[1].val.p) = outptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
|
@ -291,8 +103,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
rv = WSPFactory::MethodToPropertyName(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -316,7 +128,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
rv = VariantToResult(type_tag, params[0].val.p, iinfo, val);
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array
|
||||
|
@ -354,7 +166,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
rv = VariantToArrayResult(arrayType.TagPart(), params, iinfo, val);
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params,
|
||||
iinfo, val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -225,7 +225,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
GET_AND_TEST_NAME(p2)
|
||||
PRUint16 dataType;
|
||||
val->GetDataType(&dataType);
|
||||
if (dataType != nsIDataType::TYPE_EMPTY) {
|
||||
if (dataType != nsIDataType::VTYPE_EMPTY) {
|
||||
printf("WSPProxyTest: Value doesn't match for property p\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -235,7 +235,8 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
nsIVariant** arrayVal;
|
||||
|
||||
GET_AND_TEST_NAME(array1)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
nsIID iid;
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array1\n");
|
||||
return rv;
|
||||
|
@ -257,7 +258,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
|
||||
|
||||
GET_AND_TEST_NAME(array2)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array2\n");
|
||||
return rv;
|
||||
|
@ -279,7 +280,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
|
||||
|
||||
GET_AND_TEST_NAME(array3)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array2\n");
|
||||
return rv;
|
||||
|
@ -297,7 +298,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
}
|
||||
array3Var = arrayVal[1];
|
||||
array3Var->GetDataType(&dataType);
|
||||
if (dataType != nsIDataType::TYPE_EMPTY) {
|
||||
if (dataType != nsIDataType::VTYPE_EMPTY) {
|
||||
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -649,7 +650,7 @@ int main (int argc, char* argv[])
|
|||
{
|
||||
nsIServiceManager *servMgr;
|
||||
|
||||
nsresult rv = NS_InitXPCOM(&servMgr, nsnull);
|
||||
nsresult rv = NS_InitXPCOM2(&servMgr, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("failed to initialize XPCOM");
|
||||
return rv;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "nsIWSDL.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
#include "nsIException.idl"
|
||||
#include "nsISOAPResponse.idl"
|
||||
#include "nsISOAPBlock.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsAWritableString.h"
|
||||
|
@ -49,9 +51,6 @@
|
|||
|
||||
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 {
|
||||
|
@ -244,41 +243,6 @@ interface nsIWebServiceCallContext : nsISupports {
|
|||
*/
|
||||
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 <code>onError</code> will be invoked,
|
||||
|
@ -290,6 +254,18 @@ interface nsIWebServiceCallContext : nsISupports {
|
|||
void abort(in nsIException error);
|
||||
};
|
||||
|
||||
[scriptable, uuid(1ef83ece-b645-4b55-a501-df42c3333b47)]
|
||||
interface nsIWebServiceSOAPCallContext : nsIWebServiceCallContext {
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_WEBSERVICEPROXYFACTORY_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceproxyfactory;1"
|
||||
%}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "nsIWSDL.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
#include "nsIException.idl"
|
||||
#include "nsISOAPResponse.idl"
|
||||
#include "nsISOAPBlock.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsAWritableString.h"
|
||||
|
@ -49,9 +51,6 @@
|
|||
|
||||
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 {
|
||||
|
@ -244,41 +243,6 @@ interface nsIWebServiceCallContext : nsISupports {
|
|||
*/
|
||||
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 <code>onError</code> will be invoked,
|
||||
|
@ -290,6 +254,18 @@ interface nsIWebServiceCallContext : nsISupports {
|
|||
void abort(in nsIException error);
|
||||
};
|
||||
|
||||
[scriptable, uuid(1ef83ece-b645-4b55-a501-df42c3333b47)]
|
||||
interface nsIWebServiceSOAPCallContext : nsIWebServiceCallContext {
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_WEBSERVICEPROXYFACTORY_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceproxyfactory;1"
|
||||
%}
|
||||
|
|
|
@ -38,15 +38,21 @@ REQUIRES = xpcom \
|
|||
caps \
|
||||
js \
|
||||
necko \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS= \
|
||||
wspproxy.cpp \
|
||||
wspcallcontext.cpp \
|
||||
wspfactory.cpp \
|
||||
wspcomplextypewrapper.cpp \
|
||||
wsppropertybagwrapper.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../../soap/src \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
|
|
@ -36,10 +36,12 @@ REQUIRES = xpcom \
|
|||
caps \
|
||||
js \
|
||||
necko \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\wspproxy.obj \
|
||||
.\$(OBJDIR)\wspcallcontext.obj \
|
||||
.\$(OBJDIR)\wspfactory.obj \
|
||||
.\$(OBJDIR)\wspcomplextypewrapper.obj \
|
||||
.\$(OBJDIR)\wsppropertybagwrapper.obj \
|
||||
|
@ -48,6 +50,8 @@ CPP_OBJS= \
|
|||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I..\..\soap\src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DEPTH=..\..\..\..\..
|
||||
|
||||
XPIDL_MODULE=wsproxytest
|
||||
MODULE=wsproxytest
|
||||
|
||||
XPIDLSRCS = .\nsIWSPProxyTest.idl \
|
||||
$(NULL)
|
||||
|
|
|
@ -225,7 +225,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
GET_AND_TEST_NAME(p2)
|
||||
PRUint16 dataType;
|
||||
val->GetDataType(&dataType);
|
||||
if (dataType != nsIDataType::TYPE_EMPTY) {
|
||||
if (dataType != nsIDataType::VTYPE_EMPTY) {
|
||||
printf("WSPProxyTest: Value doesn't match for property p\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -235,7 +235,8 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
nsIVariant** arrayVal;
|
||||
|
||||
GET_AND_TEST_NAME(array1)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
nsIID iid;
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array1\n");
|
||||
return rv;
|
||||
|
@ -257,7 +258,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
|
||||
|
||||
GET_AND_TEST_NAME(array2)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array2\n");
|
||||
return rv;
|
||||
|
@ -279,7 +280,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal);
|
||||
|
||||
GET_AND_TEST_NAME(array3)
|
||||
rv = val->GetAsArray(&type, &count, (void**)&arrayVal);
|
||||
rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("WSPProxyTest: Failed getting value for property array2\n");
|
||||
return rv;
|
||||
|
@ -297,7 +298,7 @@ WSPProxyTest::TestComplexTypeWrapperInstance(nsIPropertyBag* propBag)
|
|||
}
|
||||
array3Var = arrayVal[1];
|
||||
array3Var->GetDataType(&dataType);
|
||||
if (dataType != nsIDataType::TYPE_EMPTY) {
|
||||
if (dataType != nsIDataType::VTYPE_EMPTY) {
|
||||
printf("WSPProxyTest: Value doesn't match for element of property array3\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -649,7 +650,7 @@ int main (int argc, char* argv[])
|
|||
{
|
||||
nsIServiceManager *servMgr;
|
||||
|
||||
nsresult rv = NS_InitXPCOM(&servMgr, nsnull);
|
||||
nsresult rv = NS_InitXPCOM2(&servMgr, nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("failed to initialize XPCOM");
|
||||
return rv;
|
||||
|
|
|
@ -0,0 +1,376 @@
|
|||
/* -*- 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 "wspprivate.h"
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsISOAPCall.h"
|
||||
#include "nsISOAPHeaderBlock.h"
|
||||
#include "nsISOAPParameter.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation)
|
||||
: mProxy(aProxy), mCall(aSOAPCall), mMethodName(aMethodName),
|
||||
mOperation(aOperation), mStatus(NS_ERROR_NOT_AVAILABLE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
WSPCallContext::~WSPCallContext()
|
||||
{
|
||||
NS_IF_RELEASE(mProxy);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3_CI(WSPCallContext,
|
||||
nsIWebServiceCallContext,
|
||||
nsIWebServiceSOAPCallContext,
|
||||
nsISOAPResponseListener)
|
||||
|
||||
/* readonly attribute nsIWebServiceProxy proxy; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetProxy(nsIWebServiceProxy * *aProxy)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProxy);
|
||||
|
||||
*aProxy = mProxy;
|
||||
NS_IF_ADDREF(*aProxy);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString methodName; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetMethodName(nsAString & aMethodName)
|
||||
{
|
||||
aMethodName.Assign(mMethodName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint32 status; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetStatus(PRUint32 *aStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStatus);
|
||||
*aStatus = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIException pendingException; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetPendingException(nsIException * *aPendingException)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPendingException);
|
||||
*aPendingException = mException;
|
||||
NS_IF_ADDREF(*aPendingException);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIWSDLOperation operation; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetOperation(nsIWSDLOperation * *aOperation)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOperation);
|
||||
*aOperation = mOperation;
|
||||
NS_IF_ADDREF(*aOperation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void abort (in nsIException error); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::Abort(nsIException *error)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mCompletion) {
|
||||
mException = error;
|
||||
PRBool ret;
|
||||
rv = mCompletion->Abort(&ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (ret) {
|
||||
rv = CallCompletionListener();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISOAPResponse soapResponse; */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::GetSoapResponse(nsISOAPResponse * *aSoapResponse)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSoapResponse);
|
||||
if (mCompletion) {
|
||||
return mCompletion->GetResponse(aSoapResponse);
|
||||
}
|
||||
*aSoapResponse = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse,
|
||||
nsISOAPCall *aCall,
|
||||
nsresult status,
|
||||
PRBool aLast,
|
||||
PRBool *_retval)
|
||||
{
|
||||
NS_ASSERTION(aCall == mCall, "unexpected call instance");
|
||||
NS_ASSERTION(!aLast, "only single response expected");
|
||||
mStatus = status;
|
||||
*_retval = PR_TRUE;
|
||||
CallCompletionListener();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallAsync(PRUint32 aListenerMethodIndex,
|
||||
nsISupports* aListener)
|
||||
{
|
||||
mAsyncListener = aListener;
|
||||
mListenerMethodIndex = aListenerMethodIndex;
|
||||
return mCall->AsyncInvoke(this, getter_AddRefs(mCompletion));
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsresult rv = mCall->Invoke(getter_AddRefs(response));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallCompletionListener()
|
||||
{
|
||||
nsresult rv;
|
||||
#define PARAM_BUFFER_COUNT 8
|
||||
|
||||
nsXPTCVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCVariant* dispatchParams = nsnull;
|
||||
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
mCompletion->GetResponse(getter_AddRefs(response));
|
||||
if (response) {
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
rv = response->GetFault(getter_AddRefs(fault));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (fault) {
|
||||
WSPException* exception = new WSPException(fault, mStatus);
|
||||
if (!exception) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mException = exception;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> listenerInterfaceInfo;
|
||||
mProxy->GetListenerInterfaceInfo(getter_AddRefs(listenerInterfaceInfo));
|
||||
NS_ASSERTION(listenerInterfaceInfo, "WSPCallContext:Missing listener interface info");
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
rv = listenerInterfaceInfo->GetMethodInfo(mListenerMethodIndex,
|
||||
&methodInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRUint32 paramCount = methodInfo->GetParamCount();
|
||||
if(paramCount > PARAM_BUFFER_COUNT) {
|
||||
if(!(dispatchParams = new nsXPTCVariant[paramCount])) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dispatchParams = paramBuffer;
|
||||
}
|
||||
|
||||
// iterate through the params to clear flags
|
||||
PRUint32 i;
|
||||
for(i = 0; i < paramCount; i++) {
|
||||
nsXPTCVariant* dp = &dispatchParams[i];
|
||||
dp->ClearFlags();
|
||||
dp->val.p = nsnull;
|
||||
}
|
||||
|
||||
PRUint32 headerCount, bodyCount;
|
||||
nsISOAPHeaderBlock** headerBlocks;
|
||||
nsISOAPParameter** bodyBlocks;
|
||||
|
||||
// If we have an exception, report it now
|
||||
if (mException) {
|
||||
dispatchParams[0].val.p = NS_STATIC_CAST(void*, mException);
|
||||
dispatchParams[0].SetValIsInterface();
|
||||
|
||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
paramCount, dispatchParams);
|
||||
}
|
||||
else if (response) {
|
||||
nsCOMPtr<nsIWSDLBinding> binding;
|
||||
rv = mOperation->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
PRUint16 style;
|
||||
operationBinding->GetStyle(&style);
|
||||
|
||||
rv = response->GetHeaderBlocks(&headerCount, &headerBlocks);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
rv = response->GetParameters(style == nsISOAPPortBinding::STYLE_DOCUMENT,
|
||||
&bodyCount, &bodyBlocks);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWSDLMessage> output;
|
||||
rv = mOperation->GetOutput(getter_AddRefs(output));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
PRUint32 partCount;
|
||||
output->GetPartCount(&partCount);
|
||||
|
||||
PRUint32 bodyEntry = 0, headerEntry = 0, arrayOffset = 0;
|
||||
for (i = 0; i < partCount; i++) {
|
||||
nsCOMPtr<nsIWSDLPart> part;
|
||||
rv = output->GetPart(i, getter_AddRefs(part));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
rv = part->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
PRUint16 location;
|
||||
partBinding->GetLocation(&location);
|
||||
|
||||
nsCOMPtr<nsISOAPBlock> block;
|
||||
if (location == nsISOAPPartBinding::LOCATION_HEADER) {
|
||||
block = do_QueryInterface(headerBlocks[headerEntry++]);
|
||||
}
|
||||
else if (location == nsISOAPPartBinding::LOCATION_BODY) {
|
||||
block = do_QueryInterface(bodyBlocks[bodyEntry++]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISchemaComponent> schemaComponent;
|
||||
rv = part->GetSchemaComponent(getter_AddRefs(schemaComponent));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
nsCOMPtr<nsISchemaElement> element = do_QueryInterface(schemaComponent);
|
||||
if (!element) {
|
||||
rv = element->GetType(getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = do_QueryInterface(schemaComponent);
|
||||
}
|
||||
|
||||
rv = block->SetSchemaType(type);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIVariant> value;
|
||||
rv = block->GetValue(getter_AddRefs(value));
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsXPTCVariant* vars = dispatchParams+i+1+arrayOffset;
|
||||
if (WSPProxy::IsArray(part)) {
|
||||
arrayOffset++;
|
||||
}
|
||||
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(i+1+arrayOffset);
|
||||
rv = WSPProxy::VariantToInParameter(listenerInterfaceInfo,
|
||||
mListenerMethodIndex,
|
||||
¶mInfo,
|
||||
value, vars);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
|
||||
rv = XPTC_InvokeByIndex(mAsyncListener, mListenerMethodIndex,
|
||||
paramCount, dispatchParams);
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
call_completion_end:
|
||||
if (headerCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(headerCount, headerBlocks);
|
||||
}
|
||||
if (bodyCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
if(dispatchParams && dispatchParams != paramBuffer) {
|
||||
delete [] dispatchParams;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -147,7 +147,7 @@ WSPComplexTypeEnumerator::GetNext(nsISupports **_retval)
|
|||
}
|
||||
|
||||
nsAutoString propName;
|
||||
rv = WSPFactory::MethodToPropertyName(nsDependentCString(methodInfo->GetName()), propName);
|
||||
rv = WSPFactory::C2XML(nsDependentCString(methodInfo->GetName()), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -211,172 +211,6 @@ WSPComplexTypeWrapper::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::ResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance(NS_VARIANT_CONTRACTID,
|
||||
&rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
var->SetAsInt8(aResult.val.i8);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
var->SetAsInt16(aResult.val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
var->SetAsInt32(aResult.val.i32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
var->SetAsInt64(aResult.val.i64);
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
var->SetAsUint8(aResult.val.u8);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
var->SetAsUint16(aResult.val.u16);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
var->SetAsUint32(aResult.val.u32);
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
var->SetAsUint64(aResult.val.u64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
var->SetAsFloat(aResult.val.f);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
var->SetAsDouble(aResult.val.d);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
var->SetAsBool(aResult.val.b);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
var->SetAsChar(aResult.val.c);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
var->SetAsWChar(aResult.val.wc);
|
||||
break;
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
var->SetAsAString(*((nsAString*)aResult.val.p));
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
{
|
||||
nsISupports* instance = (nsISupports*)aResult.val.p;
|
||||
if (instance) {
|
||||
// Rewrap an interface instance in a property bag
|
||||
nsCOMPtr<WSPComplexTypeWrapper> wrapper;
|
||||
rv = Create(instance, aInterfaceInfo,
|
||||
getter_AddRefs(wrapper));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
var->SetAsInterface(NS_GET_IID(nsIPropertyBag), wrapper);
|
||||
NS_RELEASE(instance);
|
||||
}
|
||||
else {
|
||||
var->SetAsEmpty();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_ERROR("Bad attribute type for complex type interface");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aVariant = var;
|
||||
NS_ADDREF(*aVariant);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::ArrayResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> retvar = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (aLength) {
|
||||
nsIVariant** entries = (nsIVariant**)nsMemory::Alloc(aLength * sizeof(nsIVariant*));
|
||||
if (!entries) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRUint32 i = 0;
|
||||
nsXPTCVariant var;
|
||||
void* array = aResult.val.p;
|
||||
nsCOMPtr<nsIVariant> element;
|
||||
|
||||
#define POPULATE(_t,_v) \
|
||||
PR_BEGIN_MACRO \
|
||||
for(i = 0; i < aLength; i++) \
|
||||
{ \
|
||||
var.type = aTypeTag; \
|
||||
var.val._v = *((_t*)array + i); \
|
||||
rv = ResultAsVariant(aTypeTag, var, aInterfaceInfo, \
|
||||
entries+i); \
|
||||
if (NS_FAILED(rv)) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8: POPULATE(PRInt8, i8); break;
|
||||
case nsXPTType::T_I16: POPULATE(PRInt16, i16); break;
|
||||
case nsXPTType::T_I32: POPULATE(PRInt32, i32); break;
|
||||
case nsXPTType::T_I64: POPULATE(PRInt64, i64); break;
|
||||
case nsXPTType::T_U8: POPULATE(PRUint8, u8); break;
|
||||
case nsXPTType::T_U16: POPULATE(PRUint16, u16); break;
|
||||
case nsXPTType::T_U32: POPULATE(PRUint32, u32); break;
|
||||
case nsXPTType::T_U64: POPULATE(PRUint64, u64); break;
|
||||
case nsXPTType::T_FLOAT: POPULATE(float, f); break;
|
||||
case nsXPTType::T_DOUBLE: POPULATE(double, d); break;
|
||||
case nsXPTType::T_BOOL: POPULATE(PRBool, b); break;
|
||||
case nsXPTType::T_CHAR: POPULATE(char, c); break;
|
||||
case nsXPTType::T_WCHAR: POPULATE(PRUnichar, wc); break;
|
||||
case nsXPTType::T_INTERFACE: POPULATE(nsISupports*, p); break;
|
||||
}
|
||||
|
||||
#undef POPULATE
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = retvar->SetAsArray(nsIDataType::TYPE_INTERFACE, aLength, entries);
|
||||
}
|
||||
|
||||
// Even if we failed while converting, we want to release
|
||||
// the entries that were already created.
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, entries);
|
||||
}
|
||||
else {
|
||||
retvar->SetAsEmpty();
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aVariant = retvar;
|
||||
NS_ADDREF(*aVariant);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* nsIVariant getProperty (in AString name); */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeWrapper::GetProperty(const nsAString & name,
|
||||
|
@ -385,7 +219,7 @@ WSPComplexTypeWrapper::GetProperty(const nsAString & name,
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsCAutoString methodName;
|
||||
WSPFactory::PropertyToMethodName(name, methodName);
|
||||
WSPFactory::XML2C(name, methodName);
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
PRUint16 methodIndex;
|
||||
|
@ -508,11 +342,12 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
|||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_ARRAY) {
|
||||
rv = ArrayResultAsVariant(arrayType.TagPart(), var[1],
|
||||
var[0].val.u32, iinfo, _retval);
|
||||
rv = WSPProxy::ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), var[1],
|
||||
var[0].val.u32, iinfo,
|
||||
_retval);
|
||||
}
|
||||
else {
|
||||
rv = ResultAsVariant(type_tag, var[0], iinfo, _retval);
|
||||
rv = WSPProxy::XPTCMiniVariantToVariant(type_tag, var[0], iinfo, _retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -80,14 +80,14 @@ WSPFactory::CreateProxyAsync(const nsAString & wsdlURL,
|
|||
#define P2M_ESCAPE_CHARACTER '_'
|
||||
|
||||
nsresult
|
||||
WSPFactory::MethodToPropertyName(const nsAReadableCString& aMethodName,
|
||||
nsAWritableString& aPropertyName)
|
||||
WSPFactory::C2XML(const nsAReadableCString& aCIdentifier,
|
||||
nsAWritableString& aXMLIdentifier)
|
||||
{
|
||||
nsReadingIterator<char> current, end;
|
||||
|
||||
aPropertyName.Truncate();
|
||||
aMethodName.BeginReading(current);
|
||||
aMethodName.EndReading(end);
|
||||
aXMLIdentifier.Truncate();
|
||||
aCIdentifier.BeginReading(current);
|
||||
aCIdentifier.EndReading(end);
|
||||
|
||||
while (current != end) {
|
||||
char ch = *current++;
|
||||
|
@ -111,21 +111,21 @@ WSPFactory::MethodToPropertyName(const nsAReadableCString& aMethodName,
|
|||
else {
|
||||
uch = PRUnichar(ch);
|
||||
}
|
||||
aPropertyName.Append(uch);
|
||||
aXMLIdentifier.Append(uch);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
WSPFactory::PropertyToMethodName(const nsAReadableString& aPropertyName,
|
||||
nsAWritableCString& aMethodName)
|
||||
WSPFactory::XML2C(const nsAReadableString& aXMLIndentifier,
|
||||
nsAWritableCString& aCIdentifier)
|
||||
{
|
||||
nsReadingIterator<PRUnichar> current, end;
|
||||
|
||||
aMethodName.Truncate();
|
||||
aPropertyName.BeginReading(current);
|
||||
aPropertyName.EndReading(end);
|
||||
aCIdentifier.Truncate();
|
||||
aXMLIndentifier.BeginReading(current);
|
||||
aXMLIndentifier.EndReading(end);
|
||||
|
||||
while (current != end) {
|
||||
PRUnichar uch = *current++;
|
||||
|
@ -133,14 +133,14 @@ WSPFactory::PropertyToMethodName(const nsAReadableString& aPropertyName,
|
|||
((PRUnichar('A') <= uch) && (uch <= PRUnichar('Z'))) ||
|
||||
((PRUnichar('0') <= uch) && (uch <= PRUnichar('9')))) {
|
||||
// Casting is safe since we know that it's an ASCII character
|
||||
aMethodName.Append(char(uch));
|
||||
aCIdentifier.Append(char(uch));
|
||||
}
|
||||
else {
|
||||
// Escape the character and append to the string
|
||||
char buf[6];
|
||||
buf[0] = P2M_ESCAPE_CHARACTER;
|
||||
PR_snprintf(buf+1, 5, "%hx", uch);
|
||||
aMethodName.Append(buf, 5);
|
||||
aCIdentifier.Append(buf, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,13 @@
|
|||
#include "nsIWebServiceProxy.h"
|
||||
#include "nsIWSDL.h"
|
||||
|
||||
// SOAP includes
|
||||
#include "nsISOAPCall.h"
|
||||
#include "nsISOAPResponse.h"
|
||||
#include "nsISOAPResponseListener.h"
|
||||
#include "nsISOAPCallCompletion.h"
|
||||
#include "nsISOAPFault.h"
|
||||
|
||||
// interface info includes
|
||||
#include "xptcall.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
@ -52,10 +59,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsIPropertyBag.h"
|
||||
|
||||
class nsISOAPCall;
|
||||
class nsISOAPResponse;
|
||||
class nsISOAPParameter;
|
||||
#include "nsIException.h"
|
||||
|
||||
class WSPFactory : public nsIWebServiceProxyFactory
|
||||
{
|
||||
|
@ -66,10 +70,10 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICEPROXYFACTORY
|
||||
|
||||
static nsresult MethodToPropertyName(const nsAReadableCString& aMethodName,
|
||||
nsAWritableString& aPropertyName);
|
||||
static void PropertyToMethodName(const nsAReadableString& aPropertyName,
|
||||
nsAWritableCString& aMethodName);
|
||||
static nsresult C2XML(const nsAReadableCString& aCIdentifier,
|
||||
nsAWritableString& aXMLIdentifier);
|
||||
static void XML2C(const nsAReadableString& aXMLIndentifier,
|
||||
nsAWritableCString& aCIdentifier);
|
||||
};
|
||||
|
||||
class WSPProxy : public nsXPTCStubBase,
|
||||
|
@ -89,41 +93,113 @@ public:
|
|||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
|
||||
nsresult Init(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
const nsAReadableString& aQualifier,
|
||||
PRBool aIsAsync);
|
||||
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
||||
|
||||
static nsresult Create(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
const nsAReadableString& aNamespace,
|
||||
const nsAReadableString& aQualifier,
|
||||
PRBool aIsAsync, WSPProxy** aProxy);
|
||||
|
||||
static nsresult XPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aIfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
|
||||
static nsresult VariantToValue(uint8 aTypeTag,
|
||||
void* aValue,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
static nsresult VariantToArrayValue(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
|
||||
static nsresult ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsXPTCMiniVariant aMiniVariant,
|
||||
PRUint32 aArrayLength,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult VariantToInParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCVariant* aXPTCVariant);
|
||||
static nsresult VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCMiniVariant* aMiniVariant);
|
||||
static PRBool IsArray(nsIWSDLPart* aPart);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWSDLPort> mPort;
|
||||
nsCOMPtr<nsIInterfaceInfo> mPrimaryInterface;
|
||||
nsString mNamespace;
|
||||
nsString mQualifier;
|
||||
PRBool mIsAsync;
|
||||
nsSupportsArray mPendingCalls;
|
||||
const nsIID* mIID;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
nsCOMPtr<nsIInterfaceInfo> mListenerInterfaceInfo;
|
||||
};
|
||||
|
||||
class WSPCallContext : public nsIWebServiceCallContext
|
||||
// public nsISOAPResponseListener
|
||||
class WSPCallContext : public nsIWebServiceSOAPCallContext,
|
||||
public nsISOAPResponseListener
|
||||
{
|
||||
public:
|
||||
WSPCallContext();
|
||||
WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation);
|
||||
virtual ~WSPCallContext();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICECALLCONTEXT
|
||||
|
||||
static nsresult Create(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAReadableString& aMethodName,
|
||||
nsIWSDLOperation* aOperation,
|
||||
WSPCallContext** aCallContext);
|
||||
NS_DECL_NSIWEBSERVICESOAPCALLCONTEXT
|
||||
NS_DECL_NSISOAPRESPONSELISTENER
|
||||
|
||||
nsresult CallAsync(PRUint32 aListenerMethodIndex,
|
||||
nsISupports* aListener);
|
||||
nsresult CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<WSPProxy> mProxy;
|
||||
// nsCOMPtr<nsISOAPCall> mSOAPCall;
|
||||
nsresult CallCompletionListener();
|
||||
|
||||
protected:
|
||||
WSPProxy* mProxy;
|
||||
nsCOMPtr<nsISOAPCall> mCall;
|
||||
nsString mMethodName;
|
||||
nsCOMPtr<nsIWSDLOperation> mOperation;
|
||||
nsCOMPtr<nsISOAPCallCompletion> mCompletion;
|
||||
nsresult mStatus;
|
||||
nsCOMPtr<nsIException> mException;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
PRUint32 mListenerMethodIndex;
|
||||
};
|
||||
|
||||
class WSPException : public nsIException
|
||||
{
|
||||
public:
|
||||
WSPException(nsISOAPFault* aFault, nsresult aStatus);
|
||||
virtual ~WSPException();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXCEPTION
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISOAPFault> mFault;
|
||||
nsresult mStatus;
|
||||
};
|
||||
|
||||
class WSPComplexTypeWrapper : public nsIPropertyBag
|
||||
|
@ -144,16 +220,6 @@ public:
|
|||
const nsXPTMethodInfo* aMethodInfo,
|
||||
nsIVariant** _retval);
|
||||
|
||||
protected:
|
||||
nsresult ResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
nsresult ArrayResultAsVariant(uint8 aTypeTag,
|
||||
nsXPTCVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mComplexTypeInstance;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
|
@ -177,16 +243,6 @@ public:
|
|||
static nsresult Create(nsIPropertyBag* aPropertyBag,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
WSPPropertyBagWrapper** aWrapper);
|
||||
protected:
|
||||
nsresult VariantToResult(uint8 aTypeTag,
|
||||
void* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
nsresult VariantToArrayResult(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIPropertyBag> mPropertyBag;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
|
|
|
@ -89,194 +89,6 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPPropertyBagWrapper::VariantToResult(uint8 aTypeTag,
|
||||
void* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
switch(aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
rv = aProperty->GetAsInt8((PRUint8*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
rv = aProperty->GetAsInt16((PRInt16*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
rv = aProperty->GetAsInt32((PRInt32*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
rv = aProperty->GetAsInt64((PRInt64*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U8:
|
||||
rv = aProperty->GetAsUint8((PRUint8*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
rv = aProperty->GetAsUint16((PRUint16*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
rv = aProperty->GetAsUint32((PRUint32*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_U64:
|
||||
rv = aProperty->GetAsUint64((PRUint64*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
rv = aProperty->GetAsFloat((float*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
rv = aProperty->GetAsDouble((double*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
rv = aProperty->GetAsBool((PRBool*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
rv = aProperty->GetAsChar((char*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
rv = aProperty->GetAsWChar((PRUnichar*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
rv = aProperty->GetAsAString(*(nsAString*)aResult);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
{
|
||||
PRUint16 dataType;
|
||||
aProperty->GetDataType(&dataType);
|
||||
if (dataType == nsIDataType::TYPE_EMPTY) {
|
||||
*(nsISupports**)aResult = nsnull;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
rv = aProperty->GetAsISupports(getter_AddRefs(sup));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIPropertyBag> propBag = do_QueryInterface(sup, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
WSPPropertyBagWrapper* wrapper;
|
||||
rv = Create(propBag, aInterfaceInfo, &wrapper);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
const nsIID* iid;
|
||||
aInterfaceInfo->GetIIDShared(&iid);
|
||||
rv = wrapper->QueryInterface(*iid, (void**)aResult);
|
||||
NS_RELEASE(wrapper);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_ERROR("Bad attribute type for complex type interface");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPPropertyBagWrapper::VariantToArrayResult(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
void* array;
|
||||
PRUint16 type;
|
||||
PRUint32 count;
|
||||
|
||||
nsresult rv = aProperty->GetAsArray(&type, &count, &array);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We assume it's an array of variants.
|
||||
// XXX need a way to confirm that
|
||||
if (type != nsIDataType::TYPE_INTERFACE) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsIVariant** variants = (nsIVariant**)array;
|
||||
|
||||
PRUint32 size;
|
||||
// Allocate the array
|
||||
switch (aTypeTag) {
|
||||
case nsXPTType::T_I8:
|
||||
case nsXPTType::T_U8:
|
||||
size = sizeof(PRUint8);
|
||||
break;
|
||||
case nsXPTType::T_I16:
|
||||
case nsXPTType::T_U16:
|
||||
size = sizeof(PRUint16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
case nsXPTType::T_U32:
|
||||
size = sizeof(PRUint32);
|
||||
break;
|
||||
case nsXPTType::T_I64:
|
||||
case nsXPTType::T_U64:
|
||||
size = sizeof(PRUint64);
|
||||
break;
|
||||
case nsXPTType::T_FLOAT:
|
||||
size = sizeof(float);
|
||||
break;
|
||||
case nsXPTType::T_DOUBLE:
|
||||
size = sizeof(double);
|
||||
break;
|
||||
case nsXPTType::T_BOOL:
|
||||
size = sizeof(PRBool);
|
||||
break;
|
||||
case nsXPTType::T_CHAR:
|
||||
size = sizeof(char);
|
||||
break;
|
||||
case nsXPTType::T_WCHAR:
|
||||
size = sizeof(PRUnichar);
|
||||
break;
|
||||
case nsXPTType::T_INTERFACE:
|
||||
size = sizeof(nsISupports*);
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unexpected array type");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void* outptr = nsMemory::Alloc(count * size);
|
||||
if (!outptr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
rv = VariantToResult(aTypeTag, (void*)((char*)outptr + (i*size)),
|
||||
aInterfaceInfo, variants[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free the variant array passed back to us
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, variants);
|
||||
|
||||
// If conversion failed, free the allocated structures
|
||||
if (NS_FAILED(rv)) {
|
||||
if (aTypeTag == nsXPTType::T_INTERFACE) {
|
||||
nsMemory::Free(outptr);
|
||||
}
|
||||
else {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, (nsISupports**)outptr);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
*((PRUint32*)aResult[0].val.p) = count;
|
||||
*((void**)aResult[1].val.p) = outptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
|
@ -291,8 +103,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
rv = WSPFactory::MethodToPropertyName(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -316,7 +128,7 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
rv = VariantToResult(type_tag, params[0].val.p, iinfo, val);
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array
|
||||
|
@ -354,7 +166,8 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
}
|
||||
|
||||
rv = VariantToArrayResult(arrayType.TagPart(), params, iinfo, val);
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params,
|
||||
iinfo, val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче