Fixed most SOAP issues brought up by reviewer. Added completion object.

Inherited SOAPParameter and SOAPHeaderBlock from SOAPBlock, improved
error condition handling, improved comments.

Not part of default build.
This commit is contained in:
rayw%netscape.com 2001-11-30 22:53:16 +00:00
parent a598e0453c
commit ca53676a88
56 changed files with 1524 additions and 1218 deletions

View File

@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
/**
* This interface encapsulates an arbitrary block to be used
* by the soap serialization or protocol. It presents the
* namespaceURI, name, encoding, schemaType, and value of the
* block. There are two different ways this may be used:
* <p>1. When created by a user for serialization, a value is set
* which is then used to encode the message. In this case, the
* user sets the value (or element in the case of a literal
* block) which is then encoded (unless it is the element)
* and incorporated into the document as it is encoded.
* <p>2. When requested by the user from a message that is to
* be decoded. In this case, an element is set on the block
* which is automatically decoded whenever the value attribute is
* accessed (possibly after the user sets the encoding or schemaType,
* or for literal blocks, the user just accesses the element and
* no decoding is performed. For SOAP which attachments, hidden
* attachments may also be associated from the message to the block
* so that later decoding which relies on the attachments is possible.
*/
[scriptable, uuid(843afaa8-1dd2-11b2-8b0d-9b5d16fe64ea)]
interface nsISOAPBlock : nsISupports {
/**
* The namespace URI of the block. Ignored if name is null.
* If this is modified, element is set to null and all
* attributes computed from element revert to previous
* uncomputed values. If element is set, this becomes computed.
*/
attribute AString namespaceURI;
/**
* The name of the block. If the block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>. If this is modified, element is set to null and all
* attributes computed from element revert to previous uncomputed
* values. If element is set, this becomes computed.
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this block.
* If this is set, value, namespaceURI, and name becomes a
* computed attributes which are produced by decoding this
* element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this block. If this is modified, element is set
* to null and all attributes computed from element
* revert to previous uncomputed values. If element
* is set, this becomes computed, relying on the
* value of encoding and schemaType each time it is
* computed.
*/
attribute nsIVariant value;
};

View File

@ -25,6 +25,7 @@
interface nsISOAPResponse;
interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
/**
* This interface is a convenience extension of the basic SOAP message,
@ -77,7 +78,7 @@ interface nsISOAPCall : nsISOAPMessage {
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
nsISOAPCallCompletion asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++

View File

@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This permits the invoker of an asynchronous call to
* abort the call before it completes or to test to
* see whether it is complete.
*/
[scriptable, uuid(86114dd8-1dd2-11b2-ab2b-91d0c995e03a)]
interface nsISOAPCallCompletion : nsISupports {
/**
* The call which was invoked (may have changed since
* the call was made).
*/
readonly attribute nsISOAPCall call;
/**
* The response, if any, to the call.
*/
readonly attribute nsISOAPResponse response;
/**
* The listener to the call.
*/
readonly attribute nsISOAPResponseListener listener;
/**
* Whether the call is complete.
*/
readonly attribute boolean isComplete;
/**
* Cause the invoked method to abort, if it is not
* already complete.
* @return true if the state of isComplete became
* true as a result. False if it was already
* true or reamined false.
*/
boolean abort();
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@ -32,9 +32,18 @@ interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
* This interface keeps track of the current encoding style and
* how objects should be encoded or decoded, as well as all
* associated encodings.
* <p>While two different nsSOAPCalls may have an encoding
* for the same styleURI, by default the encoding object and all
* associated encoding objects are local do not affect other
* calls because the encodings are local and not associated,
* unless the same or associated encodings are explicitly set
* on multiple calls. When a call is invoked, the same encoding
* object is automatically set on the response message so that
* decoders registered on the call encoding are automatically
* applied to the response.
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
@ -46,18 +55,23 @@ interface nsISOAPEncoding : nsISupports {
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
* Get an associated encoding for a different encoding style. If
* there is no default associated encoding available for the
* specified encoding style, then if aCreateIf is specified, one
* is created, otherwise a null is returned. Associated encodings
* are the set of encodings that may be used and modified together
* as a set.
*
* @param aStyleURI The style URI of the alternative encoding style.
* @param aStyleURI The style URI of the associated encoding.
*
* @param aCreateIf If true, then create the alternative style if it
* @param aCreateIf If true, then create the associated encoding if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* @return The associated encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
nsISOAPEncoding getAssociatedEncoding(
in AString aStyleURI,
in boolean aCreateIf);
@ -115,10 +129,25 @@ interface nsISOAPEncoding : nsISupports {
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* The default encoder invoked by all encoding calls. Appropriate calls
* to more-specific encoders, if any, must be dispatched by this default
* encoder. The default encoder typically looks up encoders by known
* information such as explicit or implicit types.
*/
attribute nsISOAPEncoder defaultEncoder;
/**
* The default decoder invoked by all encoding calls. Appropriate calls
* to more-specific decoders, if any, must be dispatched by this default
* decoder. The default decoder typically looks up encoders by known
* information such as explicit or implicit types.
*/
attribute nsISOAPDecoder defaultDecoder;
/**
* The schema collection used by this and all associated encodings.
*/
attribute nsISchemaCollection schemaCollection;
/**

View File

@ -20,70 +20,38 @@
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPBlock.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
* by the soap serialization or protocol. See the description of the
* nsISOAPBlock interface for information on how the basics of this
* interface works.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
interface nsISOAPHeaderBlock : nsISOAPBlock {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
* The actor URI of the header block. If element is set,
* then this is a computed value. If this is modified,
* then element is set to null and all attributes computed
* from element revert to previous uncomputed values.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
* Flags that the processor must understand this header.
* If element is set, then this is a computed value.
* If this is modified, then element is set to null and
* all attributes computed from element revert to
* previous uncomputed values.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
attribute boolean mustUnderstand;
};
%{ C++

View File

@ -20,67 +20,21 @@
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPBlock.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
* by the soap serialization or protocol. See the nsISOAPBlock
* interface for particulars about how this interface works.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
interface nsISOAPParameter : nsISOAPBlock {
};
%{ C++

View File

@ -35,22 +35,12 @@ interface nsISOAPFault;
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++

View File

@ -57,5 +57,5 @@ interface nsISOAPResponseListener : nsISupports {
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
in nsISOAPCall aCall, in nsresult status, in boolean aLast);
};

View File

@ -26,6 +26,7 @@ interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
@ -59,7 +60,7 @@ interface nsISOAPTransport : nsISupports {
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
nsISOAPCallCompletion asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);

View File

@ -33,6 +33,7 @@ REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPBlock.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \

View File

@ -43,9 +43,6 @@
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttr.h"
NS_NAMED_LITERAL_STRING(kOne,"1");
NS_NAMED_LITERAL_STRING(kZero,"0");
NS_NAMED_LITERAL_STRING(kEmpty,"");
NS_NAMED_LITERAL_STRING(kSOAPArrayTypeAttribute,"arrayType");
@ -100,12 +97,6 @@ NS_NAMED_LITERAL_STRING(kNegativeIntegerSchemaType, "negativeInteger");
NS_NAMED_LITERAL_STRING(kNonNegativeIntegerSchemaType, "nonNegativeInteger");
NS_NAMED_LITERAL_STRING(kPositiveIntegerSchemaType, "positiveInteger");
NS_NAMED_LITERAL_STRING(kTrue, "true");
NS_NAMED_LITERAL_STRING(kFalse, "false");
NS_NAMED_LITERAL_STRING(kTrueA, "1");
NS_NAMED_LITERAL_STRING(kFalseA, "0");
#define DECLARE_ENCODER(name) \
class ns##name##Encoder : \
public nsISOAPEncoder, \
@ -584,13 +575,13 @@ NS_IMETHODIMP nsBooleanEncoder::Encode(nsISOAPEncoding* aEncoding,
rc = aSource->GetAsBool(&b);
if (NS_FAILED(rc)) return rc;
if (aName.IsEmpty()) {
return EncodeSimpleValue(b ? kTrue : kFalse,
return EncodeSimpleValue(b ? nsSOAPUtils::kTrue : nsSOAPUtils::kFalse,
nsSOAPUtils::kSOAPEncodingURI,
kBooleanSchemaType,
aDestination,
aReturnValue);
}
return EncodeSimpleValue(b ? kTrue : kFalse,
return EncodeSimpleValue(b ? nsSOAPUtils::kTrue : nsSOAPUtils::kFalse,
aNamespaceURI,
aName,
aDestination,
@ -1189,11 +1180,11 @@ NS_IMETHODIMP nsBooleanEncoder::Decode(nsISOAPEncoding* aEncoding,
nsresult rc = nsSOAPUtils::GetElementTextContent(aSource, value);
if (NS_FAILED(rc)) return rc;
bool b;
if (value.Equals(kTrue)
|| value.Equals(kTrueA)) {
if (value.Equals(nsSOAPUtils::kTrue)
|| value.Equals(nsSOAPUtils::kTrueA)) {
b = PR_TRUE;
} else if (value.Equals(kFalse)
|| value.Equals(kFalseA)) {
} else if (value.Equals(nsSOAPUtils::kFalse)
|| value.Equals(nsSOAPUtils::kFalseA)) {
b = PR_FALSE;
} else return NS_ERROR_ILLEGAL_VALUE;

View File

@ -28,6 +28,7 @@
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsISOAPCallCompletion.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
@ -82,7 +83,11 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
PRUint32 status;
rv = request->GetStatus(&status);
if (NS_SUCCEEDED(rv)
&& (status < 200
|| status >= 300)) rv = NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (aResponse) {
@ -96,26 +101,7 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener, nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
@ -131,25 +117,83 @@ nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
/* readonly attribute nsISOAPCall call; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
{
*aCall = mCall;
NS_IF_ADDREF(*aCall);
return NS_OK;
}
/* readonly attribute nsISOAPResponse response; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse * *aResponse)
{
*aResponse = mRequest ? nsnull : mResponse;
NS_IF_ADDREF(*aResponse);
return NS_OK;
}
/* readonly attribute nsISOAPResponseListener listener; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener * *aListener)
{
*aListener = mListener;
NS_IF_ADDREF(*aListener);
return NS_OK;
}
/* readonly attribute boolean isComplete; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool *aIsComplete)
{
*aIsComplete = mRequest == nsnull;
return NS_OK;
}
/* boolean abort (); */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
{
if (mRequest) {
if (NS_SUCCEEDED(mRequest->Abort())) {
mRequest = nsnull;
*_retval = PR_TRUE;
return NS_OK;
}
}
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
PRUint32 status;
nsresult rv;
mRequest->GetStatus(&rv);
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
if (mRequest) { // Avoid if it has been aborted.
rv = mRequest->GetStatus(&status);
if (NS_SUCCEEDED(rv)
&& (status < 200
|| status >= 300)) rv = NS_ERROR_FAILURE;
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
rv = mResponse->SetMessage(document);
}
else {
mResponse = nsnull;
}
}
else {
mResponse = nsnull;
}
mRequest = nsnull; // Break cycle.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, rv, PR_TRUE, &c);
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse,
nsISOAPCallCompletion** aCompletion)
{
NS_ENSURE_ARG(aCall);
@ -183,22 +227,22 @@ NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponse
if (NS_FAILED(rv)) return rv;
}
if (aListener) {
nsCOMPtr<nsIDOMEventListener> listener;
listener = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument), messageDocument);
if (NS_FAILED(rv)) return rv;
if (aListener) {
*aCompletion = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!*aCompletion) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aCompletion);
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(*aCompletion);
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;

View File

@ -27,6 +27,10 @@
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsISOAPCallCompletion.h"
#include "nsISOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
@ -41,10 +45,36 @@ public:
NS_DECL_NSISOAPTRANSPORT
};
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener, public nsISOAPCallCompletion
{
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPCALLCOMPLETION
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#define NS_HTTPSOAPTRANSPORTCOMPLETION_CID \
{ /* 9032e336-1dd2-11b2-99be-a44376d4d5b1 */ \
0x9032e336, 0x1dd2, 0x11b2, \
{0x99, 0xbe, 0xa4, 0x43, 0x76, 0xd4, 0xd5, 0xb1} }
#define NS_HTTPSOAPTRANSPORTCOMPLETION_CONTRACTID "@mozilla.org/xmlextras/soap/transport/completion;1?protocol=http"
#endif

View File

@ -0,0 +1,248 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPBlock::nsSOAPBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPBlock::nsSOAPBlock(nsISOAPAttachments* aAttachments)
{
NS_INIT_ISUPPORTS();
mAttachments = aAttachments;
}
nsSOAPBlock::~nsSOAPBlock()
{
}
NS_IMPL_ISUPPORTS3(nsSOAPBlock,
nsISOAPBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetName(const nsAReadableString & aName)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement) { // Check for auto-computation
if (mComputeValue) {
mComputeValue = PR_FALSE;
if (mEncoding) {
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
else {
mStatus = NS_ERROR_NOT_INITIALIZED;
}
}
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant* aValue)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mValue = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPBlock_h__
#define nsSOAPBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPBlock : public nsISOAPBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPBlock();
nsSOAPBlock(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPBlock();
NS_DECL_ISUPPORTS
// nsISOAPBlock
NS_DECL_NSISOAPBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@ -118,7 +118,7 @@ NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener, nsISOAPCallCompletion ** aCompletion)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
@ -136,7 +136,7 @@ NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
rv = transport->AsyncCall(this, listener, response, aCompletion);
return rv;
}

View File

@ -55,7 +55,7 @@ nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
@ -212,12 +212,12 @@ NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
/* nsISOAPEncoding getAssociatedEncoding (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
return mRegistry->GetAssociatedEncoding(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */

View File

@ -32,57 +32,23 @@ nsSOAPHeaderBlock::nsSOAPHeaderBlock()
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::nsSOAPHeaderBlock(nsISOAPAttachments* aAttachments): nsSOAPBlock(aAttachments)
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPHeaderBlock, nsISOAPBlock, nsISOAPHeaderBlock)
NS_IMPL_ADDREF_INHERITED(nsSOAPHeaderBlock, nsSOAPBlock)
NS_IMPL_RELEASE_INHERITED(nsSOAPHeaderBlock, nsSOAPBlock)
NS_INTERFACE_MAP_BEGIN(nsSOAPHeaderBlock)
NS_INTERFACE_MAP_ENTRY(nsISOAPHeaderBlock)
NS_IMPL_QUERY_CLASSINFO(nsSOAPHeaderBlock)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPBlock)
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
@ -97,156 +63,36 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
/* attribute AString mustUnderstand; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool * aMustUnderstand)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
NS_ENSURE_ARG_POINTER(&aMustUnderstand);
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
nsAutoString m;
nsresult rc = mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,m);
if (NS_FAILED(rc)) return rc;
if (m.Length() == 0) *aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrueA) || m.Equals(nsSOAPUtils::kTrueA)) *aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalseA) || m.Equals(nsSOAPUtils::kFalseA)) *aMustUnderstand = PR_FALSE;
else return NS_ERROR_ILLEGAL_VALUE;
return NS_OK;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
else {
*aMustUnderstand = mMustUnderstand;
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetMustUnderstand(PRBool aMustUnderstand)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mMustUnderstand = aMustUnderstand;
return NS_OK;
}

View File

@ -33,38 +33,29 @@
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
class nsSOAPHeaderBlock : public nsSOAPBlock,
public nsISOAPHeaderBlock
{
public:
nsSOAPHeaderBlock();
nsSOAPHeaderBlock(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
PRBool mMustUnderstand;
};
#endif

View File

@ -32,198 +32,23 @@ nsSOAPParameter::nsSOAPParameter()
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::nsSOAPParameter(nsISOAPAttachments* aAttachments): nsSOAPBlock(aAttachments)
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPParameter, nsISOAPBlock, nsISOAPParameter)
NS_IMPL_ADDREF_INHERITED(nsSOAPParameter, nsSOAPBlock)
NS_IMPL_RELEASE_INHERITED(nsSOAPParameter, nsSOAPBlock)
NS_INTERFACE_MAP_BEGIN(nsSOAPParameter)
NS_INTERFACE_MAP_ENTRY(nsISOAPParameter)
NS_IMPL_QUERY_CLASSINFO(nsSOAPParameter)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPBlock)
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */

View File

@ -33,37 +33,25 @@
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
class nsSOAPParameter : public nsSOAPBlock,
public nsISOAPParameter
{
public:
nsSOAPParameter();
nsSOAPParameter(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@ -44,20 +44,6 @@ NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{

View File

@ -50,7 +50,6 @@ public:
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@ -55,6 +55,12 @@ NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/199
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kTrue, "true");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFalse, "false");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kTrueA, "1");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFalseA, "0");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,

View File

@ -89,6 +89,10 @@ public:
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
static nsDependentString kTrue;
static nsDependentString kTrueA;
static nsDependentString kFalse;
static nsDependentString kFalseA;
};
// Used to support null strings.

View File

@ -7,9 +7,10 @@
// Passed in as the response handler in the asynchronous case
// and called directly (see below) in the synchronous case
function handleResponse(resp, call, status, end) {
if (resp == null) {
return true;
function oncompletion(resp, call, status) {
if (status != 0) {
alert("Error completion: " + status);
return true;
}
// Was there a SOAP fault in the response?
@ -78,10 +79,10 @@ function makeCall(syncCall, faultCall) {
if (syncCall) {
var r = s.invoke();
handleResponse(r, s, 0, true);
oncompletion(r, s, 0);
}
else {
s.asyncInvoke(handleResponse);
s.asyncInvoke(oncompletion);
}
}
</SCRIPT>

View File

@ -91,6 +91,7 @@ NS_DECL_CLASSINFO(nsSOAPEncoding)
NS_DECL_CLASSINFO(nsSOAPHeaderBlock)
NS_DECL_CLASSINFO(nsSOAPParameter)
NS_DECL_CLASSINFO(nsHTTPSOAPTransport)
NS_DECL_CLASSINFO(nsHTTPSOAPTransportCompletion)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSchemaLoader)
NS_DECL_CLASSINFO(nsSchemaLoader)
@ -316,6 +317,12 @@ static nsModuleComponentInfo components[] = {
NS_CI_INTERFACE_GETTER_NAME(nsHTTPSOAPTransport),
nsnull, &NS_CLASSINFO_NAME(nsHTTPSOAPTransport),
nsIClassInfo::DOM_OBJECT },
{ "HTTP SOAP Transport Completion", NS_HTTPSOAPTRANSPORTCOMPLETION_CID,
NS_HTTPSOAPTRANSPORTCOMPLETION_CONTRACTID,
nsnull, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsHTTPSOAPTransportCompletion),
nsnull, &NS_CLASSINFO_NAME(nsHTTPSOAPTransportCompletion),
nsIClassInfo::DOM_OBJECT },
{ "SchemaLoader", NS_SCHEMALOADER_CID, NS_SCHEMALOADER_CONTRACTID,
nsSchemaLoaderConstructor, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSchemaLoader), nsnull,

View File

@ -31,7 +31,9 @@ XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
nsISOAPAttachments.idl \
nsISOAPBlock.idl \
nsISOAPCall.idl \
nsISOAPCallCompletion.idl \
nsISOAPDecoder.idl \
nsISOAPEncoder.idl \
nsISOAPEncoding.idl \

View File

@ -26,7 +26,9 @@ XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
.\nsISOAPAttachments.idl \
.\nsISOAPBlock.idl \
.\nsISOAPCall.idl \
.\nsISOAPCallCompletion.idl \
.\nsISOAPDecoder.idl \
.\nsISOAPEncoder.idl \
.\nsISOAPEncoding.idl \

View File

@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
/**
* This interface encapsulates an arbitrary block to be used
* by the soap serialization or protocol. It presents the
* namespaceURI, name, encoding, schemaType, and value of the
* block. There are two different ways this may be used:
* <p>1. When created by a user for serialization, a value is set
* which is then used to encode the message. In this case, the
* user sets the value (or element in the case of a literal
* block) which is then encoded (unless it is the element)
* and incorporated into the document as it is encoded.
* <p>2. When requested by the user from a message that is to
* be decoded. In this case, an element is set on the block
* which is automatically decoded whenever the value attribute is
* accessed (possibly after the user sets the encoding or schemaType,
* or for literal blocks, the user just accesses the element and
* no decoding is performed. For SOAP which attachments, hidden
* attachments may also be associated from the message to the block
* so that later decoding which relies on the attachments is possible.
*/
[scriptable, uuid(843afaa8-1dd2-11b2-8b0d-9b5d16fe64ea)]
interface nsISOAPBlock : nsISupports {
/**
* The namespace URI of the block. Ignored if name is null.
* If this is modified, element is set to null and all
* attributes computed from element revert to previous
* uncomputed values. If element is set, this becomes computed.
*/
attribute AString namespaceURI;
/**
* The name of the block. If the block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>. If this is modified, element is set to null and all
* attributes computed from element revert to previous uncomputed
* values. If element is set, this becomes computed.
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this block.
* If this is set, value, namespaceURI, and name becomes a
* computed attributes which are produced by decoding this
* element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this block. If this is modified, element is set
* to null and all attributes computed from element
* revert to previous uncomputed values. If element
* is set, this becomes computed, relying on the
* value of encoding and schemaType each time it is
* computed.
*/
attribute nsIVariant value;
};

View File

@ -25,6 +25,7 @@
interface nsISOAPResponse;
interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
/**
* This interface is a convenience extension of the basic SOAP message,
@ -77,7 +78,7 @@ interface nsISOAPCall : nsISOAPMessage {
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
nsISOAPCallCompletion asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++

View File

@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This permits the invoker of an asynchronous call to
* abort the call before it completes or to test to
* see whether it is complete.
*/
[scriptable, uuid(86114dd8-1dd2-11b2-ab2b-91d0c995e03a)]
interface nsISOAPCallCompletion : nsISupports {
/**
* The call which was invoked (may have changed since
* the call was made).
*/
readonly attribute nsISOAPCall call;
/**
* The response, if any, to the call.
*/
readonly attribute nsISOAPResponse response;
/**
* The listener to the call.
*/
readonly attribute nsISOAPResponseListener listener;
/**
* Whether the call is complete.
*/
readonly attribute boolean isComplete;
/**
* Cause the invoked method to abort, if it is not
* already complete.
* @return true if the state of isComplete became
* true as a result. False if it was already
* true or reamined false.
*/
boolean abort();
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@ -32,9 +32,18 @@ interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
* This interface keeps track of the current encoding style and
* how objects should be encoded or decoded, as well as all
* associated encodings.
* <p>While two different nsSOAPCalls may have an encoding
* for the same styleURI, by default the encoding object and all
* associated encoding objects are local do not affect other
* calls because the encodings are local and not associated,
* unless the same or associated encodings are explicitly set
* on multiple calls. When a call is invoked, the same encoding
* object is automatically set on the response message so that
* decoders registered on the call encoding are automatically
* applied to the response.
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
@ -46,18 +55,23 @@ interface nsISOAPEncoding : nsISupports {
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
* Get an associated encoding for a different encoding style. If
* there is no default associated encoding available for the
* specified encoding style, then if aCreateIf is specified, one
* is created, otherwise a null is returned. Associated encodings
* are the set of encodings that may be used and modified together
* as a set.
*
* @param aStyleURI The style URI of the alternative encoding style.
* @param aStyleURI The style URI of the associated encoding.
*
* @param aCreateIf If true, then create the alternative style if it
* @param aCreateIf If true, then create the associated encoding if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* @return The associated encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
nsISOAPEncoding getAssociatedEncoding(
in AString aStyleURI,
in boolean aCreateIf);
@ -115,10 +129,25 @@ interface nsISOAPEncoding : nsISupports {
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* The default encoder invoked by all encoding calls. Appropriate calls
* to more-specific encoders, if any, must be dispatched by this default
* encoder. The default encoder typically looks up encoders by known
* information such as explicit or implicit types.
*/
attribute nsISOAPEncoder defaultEncoder;
/**
* The default decoder invoked by all encoding calls. Appropriate calls
* to more-specific decoders, if any, must be dispatched by this default
* decoder. The default decoder typically looks up encoders by known
* information such as explicit or implicit types.
*/
attribute nsISOAPDecoder defaultDecoder;
/**
* The schema collection used by this and all associated encodings.
*/
attribute nsISchemaCollection schemaCollection;
/**

View File

@ -20,70 +20,38 @@
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPBlock.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
* by the soap serialization or protocol. See the description of the
* nsISOAPBlock interface for information on how the basics of this
* interface works.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
interface nsISOAPHeaderBlock : nsISOAPBlock {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
* The actor URI of the header block. If element is set,
* then this is a computed value. If this is modified,
* then element is set to null and all attributes computed
* from element revert to previous uncomputed values.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
* Flags that the processor must understand this header.
* If element is set, then this is a computed value.
* If this is modified, then element is set to null and
* all attributes computed from element revert to
* previous uncomputed values.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
attribute boolean mustUnderstand;
};
%{ C++

View File

@ -20,67 +20,21 @@
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPBlock.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
* by the soap serialization or protocol. See the nsISOAPBlock
* interface for particulars about how this interface works.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
interface nsISOAPParameter : nsISOAPBlock {
};
%{ C++

View File

@ -35,22 +35,12 @@ interface nsISOAPFault;
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++

View File

@ -57,5 +57,5 @@ interface nsISOAPResponseListener : nsISupports {
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
in nsISOAPCall aCall, in nsresult status, in boolean aLast);
};

View File

@ -26,6 +26,7 @@ interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
@ -59,7 +60,7 @@ interface nsISOAPTransport : nsISupports {
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
nsISOAPCallCompletion asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);

View File

@ -33,6 +33,7 @@ REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPBlock.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \

View File

@ -39,6 +39,7 @@ DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
OBJS= \
.\$(OBJDIR)\nsDefaultSOAPEncoder.obj \
.\$(OBJDIR)\nsHTTPSOAPTransport.obj \
.\$(OBJDIR)\nsSOAPBlock.obj \
.\$(OBJDIR)\nsSOAPCall.obj \
.\$(OBJDIR)\nsSOAPEncoding.obj \
.\$(OBJDIR)\nsSOAPFault.obj \

View File

@ -43,9 +43,6 @@
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttr.h"
NS_NAMED_LITERAL_STRING(kOne,"1");
NS_NAMED_LITERAL_STRING(kZero,"0");
NS_NAMED_LITERAL_STRING(kEmpty,"");
NS_NAMED_LITERAL_STRING(kSOAPArrayTypeAttribute,"arrayType");
@ -100,12 +97,6 @@ NS_NAMED_LITERAL_STRING(kNegativeIntegerSchemaType, "negativeInteger");
NS_NAMED_LITERAL_STRING(kNonNegativeIntegerSchemaType, "nonNegativeInteger");
NS_NAMED_LITERAL_STRING(kPositiveIntegerSchemaType, "positiveInteger");
NS_NAMED_LITERAL_STRING(kTrue, "true");
NS_NAMED_LITERAL_STRING(kFalse, "false");
NS_NAMED_LITERAL_STRING(kTrueA, "1");
NS_NAMED_LITERAL_STRING(kFalseA, "0");
#define DECLARE_ENCODER(name) \
class ns##name##Encoder : \
public nsISOAPEncoder, \
@ -584,13 +575,13 @@ NS_IMETHODIMP nsBooleanEncoder::Encode(nsISOAPEncoding* aEncoding,
rc = aSource->GetAsBool(&b);
if (NS_FAILED(rc)) return rc;
if (aName.IsEmpty()) {
return EncodeSimpleValue(b ? kTrue : kFalse,
return EncodeSimpleValue(b ? nsSOAPUtils::kTrue : nsSOAPUtils::kFalse,
nsSOAPUtils::kSOAPEncodingURI,
kBooleanSchemaType,
aDestination,
aReturnValue);
}
return EncodeSimpleValue(b ? kTrue : kFalse,
return EncodeSimpleValue(b ? nsSOAPUtils::kTrue : nsSOAPUtils::kFalse,
aNamespaceURI,
aName,
aDestination,
@ -1189,11 +1180,11 @@ NS_IMETHODIMP nsBooleanEncoder::Decode(nsISOAPEncoding* aEncoding,
nsresult rc = nsSOAPUtils::GetElementTextContent(aSource, value);
if (NS_FAILED(rc)) return rc;
bool b;
if (value.Equals(kTrue)
|| value.Equals(kTrueA)) {
if (value.Equals(nsSOAPUtils::kTrue)
|| value.Equals(nsSOAPUtils::kTrueA)) {
b = PR_TRUE;
} else if (value.Equals(kFalse)
|| value.Equals(kFalseA)) {
} else if (value.Equals(nsSOAPUtils::kFalse)
|| value.Equals(nsSOAPUtils::kFalseA)) {
b = PR_FALSE;
} else return NS_ERROR_ILLEGAL_VALUE;

View File

@ -28,6 +28,7 @@
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsISOAPCallCompletion.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
@ -82,7 +83,11 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
PRUint32 status;
rv = request->GetStatus(&status);
if (NS_SUCCEEDED(rv)
&& (status < 200
|| status >= 300)) rv = NS_ERROR_FAILURE;
if (NS_FAILED(rv)) return rv;
if (aResponse) {
@ -96,26 +101,7 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener, nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
@ -131,25 +117,83 @@ nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
/* readonly attribute nsISOAPCall call; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
{
*aCall = mCall;
NS_IF_ADDREF(*aCall);
return NS_OK;
}
/* readonly attribute nsISOAPResponse response; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse * *aResponse)
{
*aResponse = mRequest ? nsnull : mResponse;
NS_IF_ADDREF(*aResponse);
return NS_OK;
}
/* readonly attribute nsISOAPResponseListener listener; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener * *aListener)
{
*aListener = mListener;
NS_IF_ADDREF(*aListener);
return NS_OK;
}
/* readonly attribute boolean isComplete; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool *aIsComplete)
{
*aIsComplete = mRequest == nsnull;
return NS_OK;
}
/* boolean abort (); */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
{
if (mRequest) {
if (NS_SUCCEEDED(mRequest->Abort())) {
mRequest = nsnull;
*_retval = PR_TRUE;
return NS_OK;
}
}
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
PRUint32 status;
nsresult rv;
mRequest->GetStatus(&rv);
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
if (mRequest) { // Avoid if it has been aborted.
rv = mRequest->GetStatus(&status);
if (NS_SUCCEEDED(rv)
&& (status < 200
|| status >= 300)) rv = NS_ERROR_FAILURE;
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
rv = mResponse->SetMessage(document);
}
else {
mResponse = nsnull;
}
}
else {
mResponse = nsnull;
}
mRequest = nsnull; // Break cycle.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, rv, PR_TRUE, &c);
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse,
nsISOAPCallCompletion** aCompletion)
{
NS_ENSURE_ARG(aCall);
@ -183,22 +227,22 @@ NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponse
if (NS_FAILED(rv)) return rv;
}
if (aListener) {
nsCOMPtr<nsIDOMEventListener> listener;
listener = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument), messageDocument);
if (NS_FAILED(rv)) return rv;
if (aListener) {
*aCompletion = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!*aCompletion) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aCompletion);
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(*aCompletion);
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
rv = eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;

View File

@ -27,6 +27,10 @@
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsISOAPCallCompletion.h"
#include "nsISOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
@ -41,10 +45,36 @@ public:
NS_DECL_NSISOAPTRANSPORT
};
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener, public nsISOAPCallCompletion
{
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPCALLCOMPLETION
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#define NS_HTTPSOAPTRANSPORTCOMPLETION_CID \
{ /* 9032e336-1dd2-11b2-99be-a44376d4d5b1 */ \
0x9032e336, 0x1dd2, 0x11b2, \
{0x99, 0xbe, 0xa4, 0x43, 0x76, 0xd4, 0xd5, 0xb1} }
#define NS_HTTPSOAPTRANSPORTCOMPLETION_CONTRACTID "@mozilla.org/xmlextras/soap/transport/completion;1?protocol=http"
#endif

View File

@ -0,0 +1,248 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPBlock::nsSOAPBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPBlock::nsSOAPBlock(nsISOAPAttachments* aAttachments)
{
NS_INIT_ISUPPORTS();
mAttachments = aAttachments;
}
nsSOAPBlock::~nsSOAPBlock()
{
}
NS_IMPL_ISUPPORTS3(nsSOAPBlock,
nsISOAPBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetName(const nsAReadableString & aName)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mComputeValue = PR_TRUE;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement) { // Check for auto-computation
if (mComputeValue) {
mComputeValue = PR_FALSE;
if (mEncoding) {
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
else {
mStatus = NS_ERROR_NOT_INITIALIZED;
}
}
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant* aValue)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mValue = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPBlock_h__
#define nsSOAPBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPBlock : public nsISOAPBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPBlock();
nsSOAPBlock(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPBlock();
NS_DECL_ISUPPORTS
// nsISOAPBlock
NS_DECL_NSISOAPBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@ -118,7 +118,7 @@ NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener, nsISOAPCallCompletion ** aCompletion)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
@ -136,7 +136,7 @@ NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
rv = transport->AsyncCall(this, listener, response, aCompletion);
return rv;
}

View File

@ -55,7 +55,7 @@ nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
@ -212,12 +212,12 @@ NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
/* nsISOAPEncoding getAssociatedEncoding (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
return mRegistry->GetAssociatedEncoding(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */

View File

@ -32,57 +32,23 @@ nsSOAPHeaderBlock::nsSOAPHeaderBlock()
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::nsSOAPHeaderBlock(nsISOAPAttachments* aAttachments): nsSOAPBlock(aAttachments)
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPHeaderBlock, nsISOAPBlock, nsISOAPHeaderBlock)
NS_IMPL_ADDREF_INHERITED(nsSOAPHeaderBlock, nsSOAPBlock)
NS_IMPL_RELEASE_INHERITED(nsSOAPHeaderBlock, nsSOAPBlock)
NS_INTERFACE_MAP_BEGIN(nsSOAPHeaderBlock)
NS_INTERFACE_MAP_ENTRY(nsISOAPHeaderBlock)
NS_IMPL_QUERY_CLASSINFO(nsSOAPHeaderBlock)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPBlock)
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
@ -97,156 +63,36 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
/* attribute AString mustUnderstand; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool * aMustUnderstand)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
NS_ENSURE_ARG_POINTER(&aMustUnderstand);
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
nsAutoString m;
nsresult rc = mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,m);
if (NS_FAILED(rc)) return rc;
if (m.Length() == 0) *aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrueA) || m.Equals(nsSOAPUtils::kTrueA)) *aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalseA) || m.Equals(nsSOAPUtils::kFalseA)) *aMustUnderstand = PR_FALSE;
else return NS_ERROR_ILLEGAL_VALUE;
return NS_OK;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
else {
*aMustUnderstand = mMustUnderstand;
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetMustUnderstand(PRBool aMustUnderstand)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
mMustUnderstand = aMustUnderstand;
return NS_OK;
}

View File

@ -33,38 +33,29 @@
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
class nsSOAPHeaderBlock : public nsSOAPBlock,
public nsISOAPHeaderBlock
{
public:
nsSOAPHeaderBlock();
nsSOAPHeaderBlock(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
PRBool mMustUnderstand;
};
#endif

View File

@ -32,198 +32,23 @@ nsSOAPParameter::nsSOAPParameter()
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::nsSOAPParameter(nsISOAPAttachments* aAttachments): nsSOAPBlock(aAttachments)
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPParameter, nsISOAPBlock, nsISOAPParameter)
NS_IMPL_ADDREF_INHERITED(nsSOAPParameter, nsSOAPBlock)
NS_IMPL_RELEASE_INHERITED(nsSOAPParameter, nsSOAPBlock)
NS_INTERFACE_MAP_BEGIN(nsSOAPParameter)
NS_INTERFACE_MAP_ENTRY(nsISOAPParameter)
NS_IMPL_QUERY_CLASSINFO(nsSOAPParameter)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPBlock)
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */

View File

@ -33,37 +33,25 @@
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
class nsSOAPParameter : public nsSOAPBlock,
public nsISOAPParameter
{
public:
nsSOAPParameter();
nsSOAPParameter(nsISOAPAttachments* aAttachments);
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@ -44,20 +44,6 @@ NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{

View File

@ -50,7 +50,6 @@ public:
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@ -55,6 +55,12 @@ NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/199
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kTrue, "true");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFalse, "false");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kTrueA, "1");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFalseA, "0");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,

View File

@ -89,6 +89,10 @@ public:
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
static nsDependentString kTrue;
static nsDependentString kTrueA;
static nsDependentString kFalse;
static nsDependentString kFalseA;
};
// Used to support null strings.

View File

@ -7,9 +7,10 @@
// Passed in as the response handler in the asynchronous case
// and called directly (see below) in the synchronous case
function handleResponse(resp, call, status, end) {
if (resp == null) {
return true;
function oncompletion(resp, call, status) {
if (status != 0) {
alert("Error completion: " + status);
return true;
}
// Was there a SOAP fault in the response?
@ -78,10 +79,10 @@ function makeCall(syncCall, faultCall) {
if (syncCall) {
var r = s.invoke();
handleResponse(r, s, 0, true);
oncompletion(r, s, 0);
}
else {
s.asyncInvoke(handleResponse);
s.asyncInvoke(oncompletion);
}
}
</SCRIPT>