Reformatted files to eliminate bad tabs. Added nsISOAPPropertyBag, which

is not working perfectly WRT XPConnect, but broke nothing else.  Also
added mutator and su[pporting classes.

SOAP is not part of default build.


git-svn-id: svn://10.0.0.236/trunk@112374 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rayw%netscape.com 2002-01-17 03:23:06 +00:00
parent 86d0ecff6d
commit cf9fd6481c
91 changed files with 5180 additions and 3596 deletions

View File

@ -27,7 +27,7 @@
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
interface nsISOAPAttachments:nsISupports {
/**
* Get the attachment associated with a particular identifier.
@ -36,7 +36,7 @@ interface nsISOAPAttachments : nsISupports {
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
@ -45,6 +45,6 @@ void getAttachment(in AString aIdentifier);
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
AString attach();
};

View File

@ -49,7 +49,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(843afaa8-1dd2-11b2-8b0d-9b5d16fe64ea)]
interface nsISOAPBlock : nsISupports {
interface nsISOAPBlock:nsISupports {
/**
* Initialize the block for additional decoding information.
*
@ -57,8 +57,9 @@ interface nsISOAPBlock : nsISupports {
*
* @param aVersion SOAP version for decoding special header attributes.
*/
void init(in nsISOAPAttachments aAttachments, in unsigned short aVersion);
void init(in nsISOAPAttachments aAttachments,
in unsigned short aVersion);
/**
* The namespace URI of the block. Ignored if name is null.
* If this is modified, element is set to null and all

View File

@ -37,7 +37,7 @@ interface nsISOAPCallCompletion;
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
interface nsISOAPCall:nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
@ -59,9 +59,9 @@ interface nsISOAPCall : nsISOAPMessage {
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
@ -81,7 +81,7 @@ interface nsISOAPCall : nsISOAPMessage {
nsISOAPCallCompletion asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
%{C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \

View File

@ -33,25 +33,25 @@ interface nsISOAPResponseListener;
*/
[scriptable, uuid(86114dd8-1dd2-11b2-ab2b-91d0c995e03a)]
interface nsISOAPCallCompletion : nsISupports {
interface nsISOAPCallCompletion:nsISupports {
/**
* The call which was invoked (may have changed since
* the call was made).
*/
readonly attribute nsISOAPCall call;
readonly attribute nsISOAPCall call;
/**
* The response, if any, to the call.
*/
readonly attribute nsISOAPResponse response;
readonly attribute nsISOAPResponse response;
/**
* The listener to the call.
*/
readonly attribute nsISOAPResponseListener listener;
readonly attribute nsISOAPResponseListener listener;
/**
* Whether the call is complete.
*/
readonly attribute boolean isComplete;
readonly attribute boolean isComplete;
/**
* Cause the invoked method to abort, if it is not
@ -60,5 +60,5 @@ readonly attribute boolean isComplete;
* true as a result. False if it was already
* true or reamined false.
*/
boolean abort();
boolean abort();
};

View File

@ -35,7 +35,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
interface nsISOAPDecoder:nsISupports {
/**
* Decode the source DOM node
@ -53,9 +53,8 @@ interface nsISOAPDecoder : nsISupports {
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
nsIVariant decode(in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@ -33,7 +33,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
interface nsISOAPEncoder:nsISupports {
/**
* Encode the source variant.
@ -58,12 +58,11 @@ interface nsISOAPEncoder : nsISupports {
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
nsIDOMElement encode(in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@ -47,7 +47,7 @@ interface nsISchemaCollection;
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
interface nsISOAPEncoding:nsISupports {
/**
* The name of the encoding as it is known to SOAP.
@ -71,9 +71,8 @@ interface nsISOAPEncoding : nsISupports {
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getAssociatedEncoding(
in AString aStyleURI,
in boolean aCreateIf);
nsISOAPEncoding getAssociatedEncoding(in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
@ -155,13 +154,12 @@ interface nsISOAPEncoding : nsISupports {
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
nsIDOMElement encode(in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
@ -179,13 +177,12 @@ interface nsISOAPEncoding : nsISupports {
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
nsIVariant decode(in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
%{C++
#define NS_SOAPENCODING_CID \
{ /* db612ec6-1dd1-11b2-a8bc-e6777bf70a30 */ \
0xdb612ec6, 0x1dd1, 0x11b2, \

View File

@ -31,7 +31,7 @@ interface nsIDOMElement;
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
interface nsISOAPFault:nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
@ -47,7 +47,7 @@ interface nsISOAPFault : nsISupports {
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
@ -59,7 +59,7 @@ interface nsISOAPFault : nsISupports {
readonly attribute nsIDOMElement detail;
};
%{ C++
%{C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \

View File

@ -35,7 +35,7 @@ interface nsISchemaType;
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISOAPBlock {
interface nsISOAPHeaderBlock:nsISOAPBlock {
/**
* The actor URI of the header block. If element is set,
* then this is a computed value. If this is modified,
@ -54,7 +54,7 @@ interface nsISOAPHeaderBlock : nsISOAPBlock {
attribute boolean mustUnderstand;
};
%{ C++
%{C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \

View File

@ -41,11 +41,11 @@ interface nsIVariant;
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
interface nsISOAPMessage:nsISupports {
const unsigned short VERSION_1_1 = 0;
const unsigned short VERSION_1_2 = 1;
const unsigned short VERSION_UNKNOWN = 32767;
const unsigned short VERSION_1_1 = 0;
const unsigned short VERSION_1_2 = 1;
const unsigned short VERSION_UNKNOWN = 32767;
/**
* The document which captures the message, if any. A simple
@ -113,7 +113,7 @@ interface nsISOAPMessage : nsISupports {
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
@ -152,13 +152,15 @@ interface nsISOAPMessage : nsISupports {
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in unsigned short aVersion,
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
void encode(in unsigned short aVersion,
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array,
size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock
aHeaderBlocks, in PRUint32 aParameterCount,[array,
size_is
(aParameterCount)]
in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
@ -170,7 +172,8 @@ interface nsISOAPMessage : nsISupports {
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
[array, size_is(aCount),
retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
@ -187,8 +190,9 @@ interface nsISOAPMessage : nsISupports {
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
out PRUint32 aCount,
[array, size_is(aCount),
retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established

View File

@ -34,10 +34,10 @@ interface nsISchemaType;
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISOAPBlock {
interface nsISOAPParameter:nsISOAPBlock {
};
%{ C++
%{C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \

View File

@ -0,0 +1,60 @@
/* -*- 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 nsIPropertyBag;
interface nsIVariant;
/**
* This permits construction by native or
* script code a property bag that is also
* usable by other xpconnect systems.
*/
[scriptable, uuid(f34cb3c8-1dd1-11b2-8a18-a93a99d92c08)]
interface nsISOAPPropertyBagMutator:nsISupports {
/**
* The property bag that is being constructed.
* After the mutator is destroyed, this is
* read-only. This will never be null.
*/
readonly attribute nsIPropertyBag propertyBag;
/**
* Add or replace a property to the
* newly-constructed property bag.
*
* @param aName The name of the property.
*
* @param aValue The value of the property.
*/
void addProperty(in AString aName, in nsIVariant aValue);
};
%{C++
#define NS_SOAPPROPERTYBAGMUTATOR_CID \
{ /* c63d2762-1dd1-11b2-b028-8f244edaa8a1 */ \
0xc63d2762, 0x1dd1, 0x11b2, \
{0xb0, 0x28, 0x8f, 0x24, 0x4e, 0xda, 0xa8, 0xa1} }
#define NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID \
"@mozilla.org/xmlextras/soap/propertybagmutator;1"
%}

View File

@ -34,7 +34,7 @@ interface nsISOAPFault;
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
interface nsISOAPResponse:nsISOAPMessage {
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
@ -43,7 +43,7 @@ interface nsISOAPResponse : nsISOAPMessage {
readonly attribute nsISOAPFault fault;
};
%{ C++
%{C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \

View File

@ -31,8 +31,9 @@ interface nsISOAPResponse;
* responses are expected.
*/
[scriptable, function, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
[scriptable, function,
uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener:nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
@ -55,7 +56,8 @@ interface nsISOAPResponseListener : nsISupports {
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in nsresult status, in boolean aLast);
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in nsresult status,
in boolean aLast);
};

View File

@ -33,7 +33,7 @@ interface nsISOAPResponseListener;
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
interface nsISOAPService:nsISupports {
/**
* Configuration object that may contain more info on the service
*/
@ -51,11 +51,11 @@ interface nsISOAPService : nsISupports {
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
%{C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \

View File

@ -77,7 +77,7 @@ interface nsISOAPServiceRegistry {
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
%{C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \

View File

@ -29,7 +29,7 @@ interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
interface nsISOAPTransport:nsISupports {
/**
* Send the specified message to the specified destination.
@ -42,8 +42,7 @@ interface nsISOAPTransport : nsISupports {
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
void syncCall(in nsISOAPCall aCall, in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
@ -61,8 +60,8 @@ interface nsISOAPTransport : nsISupports {
* null if listener is null.
*/
nsISOAPCallCompletion asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
@ -79,7 +78,8 @@ interface nsISOAPTransport : nsISupports {
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
void addListener(in nsISOAPTransportListener aListener,
in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
@ -93,10 +93,11 @@ interface nsISOAPTransport : nsISupports {
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
void removeListener(in nsISOAPTransportListener aListener,
in boolean aCapture);
};
%{ C++
%{C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="

View File

@ -30,8 +30,9 @@ interface nsISOAPMessage;
* is recieved on a transport.
*/
[scriptable, function, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
[scriptable, function,
uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener:nsISupports {
/**
* This method is invoked when an unsolicited message is

View File

@ -40,6 +40,7 @@ CPPSRCS = \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPPropertyBag.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)

View File

@ -25,14 +25,12 @@
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder_1_1 : public nsSOAPEncoding
{
class nsDefaultSOAPEncoder_1_1:public nsSOAPEncoding {
public:
nsDefaultSOAPEncoder_1_1();
};
class nsDefaultSOAPEncoder_1_2 : public nsSOAPEncoding
{
class nsDefaultSOAPEncoder_1_2:public nsSOAPEncoding {
public:
nsDefaultSOAPEncoder_1_2();
};

View File

@ -42,7 +42,6 @@ nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
#ifdef DEBUG
#define DEBUG_DUMP_DOCUMENT(message,doc) \
{ \
@ -55,95 +54,104 @@ NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
nsAutoString result(serial);\
printf(message ":\n%s\n", NS_ConvertUCS2toUTF8(result).get());\
}
// Availble from the debugger...
nsresult DebugPrintDOM(nsIDOMNode* node)
nsresult DebugPrintDOM(nsIDOMNode * node)
{
DEBUG_DUMP_DOCUMENT("DOM", node)
return NS_OK;
DEBUG_DUMP_DOCUMENT("DOM", node) return NS_OK;
}
#else
#define DEBUG_DUMP_DOCUMENT(message,doc)
#endif
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall * aCall,
nsISOAPResponse * aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr < nsIXMLHttpRequest > request;
nsCOMPtr<nsIDOMDocument> messageDocument;
nsCOMPtr < nsIDOMDocument > messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (!messageDocument)
return NS_ERROR_NOT_INITIALIZED;
DEBUG_DUMP_DOCUMENT("Synchronous Request", messageDocument)
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (AStringIsNull(uri))
return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
rv = request->SetRequestHeader("SOAPAction",
NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv))
return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
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;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument),
messageDocument);
if (NS_FAILED(rv))
return rv;
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return 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 (NS_SUCCEEDED(rv) && (status < 200 || status >= 300))
rv = NS_ERROR_FAILURE;
if (NS_FAILED(rv))
return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
nsCOMPtr < nsIDOMDocument > response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (response) {
DEBUG_DUMP_DOCUMENT("Asynchronous Response", response)
}
DEBUG_DUMP_DOCUMENT("Asynchronous Response", response)}
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
return NS_OK;
}
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener, nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener,
nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsISOAPCall *call,
nsISOAPResponse *response,
nsIXMLHttpRequest *request,
nsISOAPResponseListener *listener):
mCall(call), mResponse(response), mRequest(request), mListener(listener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(nsISOAPCall * call, nsISOAPResponse * response, nsIXMLHttpRequest * request, nsISOAPResponseListener * listener):
mCall(call), mResponse(response), mRequest(request), mListener(listener)
{
NS_INIT_ISUPPORTS();
}
@ -151,6 +159,7 @@ nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
/* readonly attribute nsISOAPCall call; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
{
@ -160,15 +169,20 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
}
/* readonly attribute nsISOAPResponse response; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse * *aResponse)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse *
*aResponse)
{
*aResponse = mRequest ? (nsCOMPtr<nsISOAPResponse>)nsnull : mResponse;
*aResponse =
mRequest ? (nsCOMPtr < nsISOAPResponse >) nsnull : mResponse;
NS_IF_ADDREF(*aResponse);
return NS_OK;
}
/* readonly attribute nsISOAPResponseListener listener; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener * *aListener)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener *
*aListener)
{
*aListener = mListener;
NS_IF_ADDREF(*aListener);
@ -176,14 +190,15 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener
}
/* readonly attribute boolean isComplete; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool *aIsComplete)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool * aIsComplete)
{
*aIsComplete = mRequest == nsnull;
return NS_OK;
}
/* boolean abort (); */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool * _retval)
{
if (mRequest) {
if (NS_SUCCEEDED(mRequest->Abort())) {
@ -195,96 +210,120 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent * aEvent)
{
PRUint32 status;
nsresult rv;
if (mRequest) { // Avoid if it has been aborted.
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 (NS_SUCCEEDED(rv) && (status < 200 || status >= 300))
rv = NS_ERROR_FAILURE;
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
nsCOMPtr < nsIDOMDocument > document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
rv = mResponse->SetMessage(document);
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)
rv = mResponse->SetMessage(document);
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)} else {
mResponse = nsnull;
}
else {
mResponse = nsnull;
}
}
else {
} else {
mResponse = nsnull;
}
nsCOMPtr<nsISOAPCallCompletion> kungFuDeathGrip = this;
mRequest = nsnull; // Break cycle of references by releas.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
nsCOMPtr < nsISOAPCallCompletion > kungFuDeathGrip = this;
mRequest = nsnull; // Break cycle of references by releas.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, 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,
nsISOAPCallCompletion** aCompletion)
NS_IMETHODIMP
nsHTTPSOAPTransport::AsyncCall(nsISOAPCall * aCall,
nsISOAPResponseListener * aListener,
nsISOAPResponse * aResponse,
nsISOAPCallCompletion ** aCompletion)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr < nsIXMLHttpRequest > request;
nsCOMPtr<nsIDOMDocument> messageDocument;
nsCOMPtr < nsIDOMDocument > messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (!messageDocument)
return NS_ERROR_NOT_INITIALIZED;
DEBUG_DUMP_DOCUMENT("Asynchronous Request", messageDocument)
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMEventTarget > eventTarget =
do_QueryInterface(request, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (AStringIsNull(uri))
return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
rv = request->SetRequestHeader("SOAPAction",
NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv))
return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
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;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument),
messageDocument);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISOAPCallCompletion> completion;
nsCOMPtr < nsISOAPCallCompletion > completion;
if (aListener) {
completion = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!completion) return NS_ERROR_OUT_OF_MEMORY;
completion =
new nsHTTPSOAPTransportCompletion(aCall, aResponse, request,
aListener);
if (!completion)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(completion);
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 < nsIDOMEventListener > listener =
do_QueryInterface(completion);
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;
if (NS_FAILED(rv))
return rv;
*aCompletion = completion;
NS_IF_ADDREF(*aCompletion);
@ -293,15 +332,19 @@ NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponse
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
NS_IMETHODIMP
nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener * aListener,
PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
NS_IMETHODIMP
nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *
aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
nsHTTPSSOAPTransport::nsHTTPSSOAPTransport()

View File

@ -33,46 +33,41 @@
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
class nsHTTPSOAPTransport:public nsISOAPTransport {
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
virtual ~ nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT};
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
class nsHTTPSSOAPTransport: public nsHTTPSOAPTransport
{
class nsHTTPSSOAPTransport:public nsHTTPSOAPTransport {
public:
nsHTTPSSOAPTransport();
virtual ~nsHTTPSSOAPTransport();
virtual ~ nsHTTPSSOAPTransport();
NS_DECL_ISUPPORTS
};
NS_DECL_ISUPPORTS};
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener, public nsISOAPCallCompletion
{
class nsHTTPSOAPTransportCompletion:public nsIDOMEventListener,
public nsISOAPCallCompletion {
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall * call,
nsISOAPResponse * response,
nsIXMLHttpRequest * request,
nsISOAPResponseListener * listener);
virtual ~ nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPCALLCOMPLETION
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
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;
nsCOMPtr < nsISOAPCall > mCall;
nsCOMPtr < nsISOAPResponse > mResponse;
nsCOMPtr < nsIXMLHttpRequest > mRequest;
nsCOMPtr < nsISOAPResponseListener > mListener;
};
#define NS_HTTPSOAPTRANSPORT_CID \

View File

@ -37,13 +37,12 @@ nsSOAPBlock::~nsSOAPBlock()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPBlock,
nsISOAPBlock,
nsIJSNativeInitializer)
NS_IMETHODIMP nsSOAPBlock::Init(nsISOAPAttachments* aAttachments, PRUint16 aVersion) {
NS_IMPL_ISUPPORTS2(nsSOAPBlock, nsISOAPBlock, nsIJSNativeInitializer)
NS_IMETHODIMP nsSOAPBlock::Init(nsISOAPAttachments * aAttachments,
PRUint16 aVersion)
{
if (aVersion == nsISOAPMessage::VERSION_1_1
||aVersion == nsISOAPMessage::VERSION_1_2) {
|| aVersion == nsISOAPMessage::VERSION_1_2) {
mAttachments = aAttachments;
mVersion = aVersion;
return NS_OK;
@ -57,16 +56,17 @@ NS_IMETHODIMP nsSOAPBlock::GetNamespaceURI(nsAString & aNamespaceURI)
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
} else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetNamespaceURI(const nsAString & aNamespaceURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
@ -77,29 +77,31 @@ NS_IMETHODIMP nsSOAPBlock::GetName(nsAString & aName)
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
} else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetName(const nsAString & aName)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
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)
NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding * aEncoding)
{
mEncoding = aEncoding;
mComputeValue = PR_TRUE;
@ -107,14 +109,15 @@ NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding* aEncoding)
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPBlock::GetSchemaType(nsISchemaType* * aSchemaType)
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)
NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType * aSchemaType)
{
mSchemaType = aSchemaType;
mComputeValue = PR_TRUE;
@ -122,14 +125,15 @@ NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType* aSchemaType)
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPBlock::GetElement(nsIDOMElement* * aElement)
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)
NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement * aElement)
{
mElement = aElement;
mComputeValue = PR_TRUE;
@ -137,16 +141,17 @@ NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement* aElement)
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant * *aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement) { // Check for auto-computation
if (mElement) { // Check for auto-computation
if (mComputeValue) {
mComputeValue = PR_FALSE;
if (mEncoding) {
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
else {
mStatus =
mEncoding->Decode(mElement, mSchemaType, mAttachments,
getter_AddRefs(mValue));
} else {
mStatus = NS_ERROR_NOT_INITIALIZED;
}
}
@ -156,51 +161,60 @@ NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant* aValue)
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant * aValue)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mValue = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
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;
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;
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;
if (NS_FAILED(rc))
return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
nsCOMPtr < nsISchemaType > v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc))
return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
nsCOMPtr < nsISOAPEncoding > v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc))
return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
}
return NS_OK;

View File

@ -33,30 +33,26 @@
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPBlock : public nsISOAPBlock,
public nsIJSNativeInitializer
{
class nsSOAPBlock:public nsISOAPBlock, public nsIJSNativeInitializer {
public:
nsSOAPBlock();
virtual ~nsSOAPBlock();
virtual ~ nsSOAPBlock();
NS_DECL_ISUPPORTS
// nsISOAPBlock
// nsISOAPBlock
NS_DECL_NSISOAPBLOCK
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
// 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;
nsCOMPtr < nsISOAPEncoding > mEncoding;
nsCOMPtr < nsISchemaType > mSchemaType;
nsCOMPtr < nsISOAPAttachments > mAttachments;
nsCOMPtr < nsIDOMElement > mElement;
nsCOMPtr < nsIVariant > mValue;
nsresult mStatus;
PRBool mComputeValue;
PRBool mVersion;

View File

@ -43,14 +43,12 @@ nsSOAPCall::~nsSOAPCall()
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAString & aTransportURI)
{
@ -58,32 +56,35 @@ NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAString & aTransportURI)
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
nsresult nsSOAPCall::GetTransport(nsISOAPTransport ** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsCOMPtr < nsIURI > uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsISOAPTransport > transport =
do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv))
return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
@ -92,55 +93,68 @@ nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse ** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
nsCOMPtr < nsISOAPTransport > transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISOAPResponse >
response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDOMDocument> document;
rv = response->GetMessage(getter_AddRefs(document)); // No XML response.
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMDocument > document;
rv = response->GetMessage(getter_AddRefs(document)); // No XML response.
if (NS_FAILED(rv))
return rv;
if (!document) {
*_retval = nsnull;
return NS_OK;
}
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
return response->QueryInterface(NS_GET_IID(nsISOAPResponse),
(void **) _retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener, nsISOAPCallCompletion ** aCompletion)
NS_IMETHODIMP
nsSOAPCall::AsyncInvoke(nsISOAPResponseListener * listener,
nsISOAPCallCompletion ** aCompletion)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
nsCOMPtr < nsISOAPTransport > transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISOAPResponse >
response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = transport->AsyncCall(this, listener, response, aCompletion);
return rv;

View File

@ -30,25 +30,19 @@
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
class nsSOAPCall:public nsSOAPMessage, public nsISOAPCall {
public:
nsSOAPCall();
virtual ~nsSOAPCall();
virtual ~ nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL protected:
// nsISOAPCall
NS_DECL_NSISOAPCALL
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport ** aTransport);
};
#endif

View File

@ -36,9 +36,8 @@
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry, nsISOAPEncoding) nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding * aEncoding):mEncodings(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -55,21 +54,24 @@ nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(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);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
*aEncoding = (nsISOAPEncoding *) mEncodings->Get(&styleKey);
if (!*aEncoding) {
nsCOMPtr < nsISOAPEncoding > defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
nsCOMPtr < nsISOAPEncoding > encoding =
do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
*aEncoding = encoding;
NS_IF_ADDREF(*aEncoding);
mEncodings->Put(&styleKey, encoding);
@ -77,21 +79,30 @@ nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(const nsAString& aStyleUR
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
nsresult
nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection *
aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
nsresult
nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection **
aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsISchemaLoader > loader =
do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
if (!mSchemaCollection)
return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
@ -101,71 +112,99 @@ nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSche
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aKey, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aKey, nsISOAPEncoder *aEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetEncoder(const nsAString & aKey,
nsISOAPEncoder * aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aKey, nsISOAPEncoder **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetEncoder(const nsAString & aKey,
nsISOAPEncoder ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aKey, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aKey, nsISOAPDecoder *aDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDecoder(const nsAString & aKey,
nsISOAPDecoder * aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aKey, nsISOAPDecoder **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDecoder(const nsAString & aKey,
nsISOAPDecoder ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder *
*aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder *
aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder *
*aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder *
aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::Encode(nsIVariant * aSource,
const nsAString & aNamespaceURI,
const nsAString & aName,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIDOMElement * aDestination,
nsIDOMElement ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::Decode(nsIDOMElement * aSource,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIVariant ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS1_CI(nsSOAPEncoding, nsISOAPEncoding)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
NS_IMPL_ISUPPORTS1_CI(nsSOAPEncoding, nsISOAPEncoding) nsSOAPEncoding::nsSOAPEncoding():mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -176,20 +215,24 @@ nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(PRUint16 aVersion): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
nsSOAPEncoding::nsSOAPEncoding(PRUint16 aVersion):mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(*nsSOAPUtils::kSOAPEncURI[aVersion]);
mDefaultEncoding = do_GetService(aVersion ? NS_DEFAULTSOAPENCODER_1_2_CONTRACTID : NS_DEFAULTSOAPENCODER_1_1_CONTRACTID);
mDefaultEncoding =
do_GetService(aVersion ? NS_DEFAULTSOAPENCODER_1_2_CONTRACTID :
NS_DEFAULTSOAPENCODER_1_1_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
nsSOAPEncoding::nsSOAPEncoding(const nsAString & aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding * aDefaultEncoding):mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -207,12 +250,17 @@ nsSOAPEncoding::~nsSOAPEncoding()
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
nsresult
nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection *
aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
nsresult
nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection **
aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
@ -227,7 +275,10 @@ NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
}
/* nsISOAPEncoding getAssociatedEncoding (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI,
PRBool aCreateIf,
nsISOAPEncoding ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
@ -235,27 +286,30 @@ NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI,
}
/* nsISOAPEncoder setEncoder (in AString aKey, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aKey, nsISOAPEncoder *aEncoder)
NS_IMETHODIMP
nsSOAPEncoding::SetEncoder(const nsAString & aKey,
nsISOAPEncoder * aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG(aEncoder);
nsStringKey nameKey(aKey);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
} else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aKey, nsISOAPEncoder **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetEncoder(const nsAString & aKey,
nsISOAPEncoder ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aKey);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
*_retval = (nsISOAPEncoder *) mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aKey, _retval);
}
@ -263,27 +317,30 @@ NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aKey, nsISOAPEncoder
}
/* nsISOAPDecoder setDecoder (in AString aKey, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aKey, nsISOAPDecoder *aDecoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDecoder(const nsAString & aKey,
nsISOAPDecoder * aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG(aDecoder);
nsStringKey nameKey(aKey);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
} else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aKey, nsISOAPDecoder **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetDecoder(const nsAString & aKey,
nsISOAPDecoder ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aKey);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
*_retval = (nsISOAPDecoder *) mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aKey, _retval);
}
@ -291,39 +348,55 @@ NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aKey, nsISOAPDecoder
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
NS_IMETHODIMP
nsSOAPEncoding::Encode(nsIVariant * aSource,
const nsAString & aNamespaceURI,
const nsAString & aName,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIDOMElement * aDestination,
nsIDOMElement ** _retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsCOMPtr < nsISOAPEncoder > encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
return encoder->Encode(this, aSource, aNamespaceURI, aName,
aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
NS_IMETHODIMP
nsSOAPEncoding::Decode(nsIDOMElement * aSource,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIVariant ** _retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsCOMPtr < nsISOAPDecoder > decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
return decoder->Decode(this, aSource, aSchemaType, aAttachments,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
@ -333,14 +406,17 @@ NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncode
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
@ -349,9 +425,11 @@ NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecode
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;

View File

@ -35,39 +35,33 @@
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
class nsSOAPEncodingRegistry:public nsISOAPEncoding {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
NS_DECL_ISUPPORTS NS_DECL_NSISOAPENCODING nsSOAPEncodingRegistry() {
} nsSOAPEncodingRegistry(nsISOAPEncoding * aEncoding);
virtual ~ nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
nsSupportsHashtable * mEncodings;
nsCOMPtr < nsISchemaCollection > mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding
{
class nsSOAPEncoding:public nsISOAPEncoding {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncoding();
NS_DECL_ISUPPORTS NS_DECL_NSISOAPENCODING nsSOAPEncoding();
nsSOAPEncoding(PRUint16 aVersion);
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
nsSOAPEncoding(const nsAString & aStyleURI,
nsSOAPEncodingRegistry * aRegistry,
nsISOAPEncoding * aDefaultEncoding);
virtual ~ nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
nsSupportsHashtable *mEncoders;
nsSupportsHashtable *mDecoders;
nsCOMPtr < nsISOAPEncoding > mRegistry;
nsCOMPtr < nsISOAPEncoding > mDefaultEncoding;
nsCOMPtr < nsISOAPEncoder > mDefaultEncoder;
nsCOMPtr < nsISOAPDecoder > mDefaultDecoder;
};
#endif

View File

@ -35,35 +35,37 @@ nsSOAPFault::~nsSOAPFault()
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPFault, nsISOAPFault)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement * aElement)
{
if (aElement) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = aElement->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = aElement->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kFaultTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
mVersion = nsISOAPMessage::VERSION_1_2;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
mVersion = nsISOAPMessage::VERSION_1_1;
}
else {
if (namespaceURI.
Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
mVersion = nsISOAPMessage::VERSION_1_2;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
mVersion = nsISOAPMessage::VERSION_1_1;
} else {
return NS_ERROR_ILLEGAL_VALUE;
}
}
else {
} else {
return NS_ERROR_ILLEGAL_VALUE;
}
}
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
@ -76,13 +78,14 @@ NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
nsCOMPtr < nsIDOMElement > faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
@ -93,12 +96,15 @@ NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAString & aFaultCode)
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultStringTagName,
getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
@ -109,12 +115,15 @@ NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultActorTagName,
getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
@ -125,10 +134,13 @@ NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultDetailTagName, aDetail);
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultDetailTagName,
aDetail);
return NS_OK;
}

View File

@ -28,19 +28,15 @@
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault
{
class nsSOAPFault:public nsISOAPFault {
public:
nsSOAPFault();
virtual ~nsSOAPFault();
virtual ~ nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
// nsISOAPFault
NS_DECL_NSISOAPFAULT protected:
nsCOMPtr < nsIDOMElement > mFaultElement;
PRUint16 mVersion;
};
#endif

View File

@ -33,16 +33,15 @@ nsSOAPHeaderBlock::nsSOAPHeaderBlock()
NS_INIT_ISUPPORTS();
}
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_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()
{
}
@ -51,46 +50,64 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN) return NS_ERROR_NOT_AVAILABLE;
return mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN)
return NS_ERROR_NOT_AVAILABLE;
return mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kActorAttribute,
aActorURI);
} else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAString & aActorURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute AString mustUnderstand; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool * aMustUnderstand)
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool *
aMustUnderstand)
{
NS_ENSURE_ARG_POINTER(&aMustUnderstand);
if (mElement) {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN) return NS_ERROR_NOT_AVAILABLE;
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN)
return NS_ERROR_NOT_AVAILABLE;
nsAutoString m;
nsresult rc = mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],nsSOAPUtils::kMustUnderstandAttribute,m);
if (NS_FAILED(rc)) return rc;
if (m.Length() == 0) *aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrue) || m.Equals(nsSOAPUtils::kTrueA)) *aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalse) || m.Equals(nsSOAPUtils::kFalseA)) *aMustUnderstand = PR_FALSE;
else return NS_ERROR_ILLEGAL_VALUE;
nsresult
rc =
mElement->
GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kMustUnderstandAttribute, m);
if (NS_FAILED(rc))
return rc;
if (m.Length() == 0)
*aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrue)
|| m.Equals(nsSOAPUtils::kTrueA))
*aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalse)
|| m.Equals(nsSOAPUtils::kFalseA))
*aMustUnderstand = PR_FALSE;
else
return NS_ERROR_ILLEGAL_VALUE;
return NS_OK;
}
else {
} else {
*aMustUnderstand = mMustUnderstand;
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetMustUnderstand(PRBool aMustUnderstand)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mMustUnderstand = aMustUnderstand;
return NS_OK;
}

View File

@ -34,22 +34,15 @@
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPHeaderBlock : public nsSOAPBlock,
public nsISOAPHeaderBlock
{
class nsSOAPHeaderBlock:public nsSOAPBlock, public nsISOAPHeaderBlock {
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
virtual ~ nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
protected:
nsString mActorURI;
NS_DECL_ISUPPORTS NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK protected:
nsString mActorURI;
PRBool mMustUnderstand;
};

View File

@ -39,7 +39,7 @@ static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
@ -49,9 +49,7 @@ nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS1(nsSOAPMessage,
nsISOAPMessage)
NS_IMPL_ISUPPORTS1(nsSOAPMessage, nsISOAPMessage)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
@ -60,6 +58,7 @@ NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
@ -72,53 +71,63 @@ NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = root->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = root->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
|| namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
&& (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
|| namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1]))) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute PRUint16 version; */
NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 *aVersion)
NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 * aVersion)
{
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = root->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = root->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aVersion = nsISOAPMessage::VERSION_1_2;
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aVersion = nsISOAPMessage::VERSION_1_2;
return NS_OK;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aVersion = nsISOAPMessage::VERSION_1_1;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aVersion = nsISOAPMessage::VERSION_1_1;
return NS_OK;
}
}
}
}
}
*aVersion = nsISOAPMessage::VERSION_UNKNOWN;
return NS_OK;
@ -128,7 +137,7 @@ NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 *aVersion)
PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
{
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
@ -136,18 +145,21 @@ PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
root->GetNamespaceURI(namespaceURI);
root->GetLocalName(name);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_2;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_1;
}
}
}
}
}
*aEnvelope = nsnull;
return nsISOAPMessage::VERSION_UNKNOWN;
@ -157,14 +169,15 @@ PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
nsCOMPtr < nsIDOMElement > env;
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kHeaderTagName,
aHeader);
} else {
*aHeader = nsnull;
}
return NS_OK;
@ -174,14 +187,14 @@ NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
nsCOMPtr < nsIDOMElement > env;
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kBodyTagName,
aBody);
}
else {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kBodyTagName, aBody);
} else {
*aBody = nsnull;
}
return NS_OK;
@ -194,6 +207,7 @@ NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAString & aActionURI)
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAString & aActionURI)
{
mActionURI.Assign(aActionURI);
@ -204,10 +218,10 @@ NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAString & aActionURI)
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsCOMPtr < nsIDOMElement > method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
@ -219,13 +233,14 @@ NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
NS_IMETHODIMP nsSOAPMessage::
GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsCOMPtr < nsIDOMElement > method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
@ -236,183 +251,236 @@ NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
return NS_OK;
}
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1, "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/1999/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2, "<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1,
"<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/1999/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2,
"<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
const nsAString* kEmptySOAPDocStr[] = {&realEmptySOAPDocStr1, &realEmptySOAPDocStr2};
const nsAString *kEmptySOAPDocStr[] =
{ &realEmptySOAPDocStr1, &realEmptySOAPDocStr2
};
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(PRUint16 aVersion, const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
NS_IMETHODIMP
nsSOAPMessage::Encode(PRUint16 aVersion, const nsAString & aMethodName,
const nsAString & aTargetObjectURI,
PRUint32 aHeaderBlockCount,
nsISOAPHeaderBlock ** aHeaderBlocks,
PRUint32 aParameterCount,
nsISOAPParameter ** aParameters)
{
if (aVersion != nsISOAPMessage::VERSION_1_1
&& aVersion != nsISOAPMessage::VERSION_1_2)
return NS_ERROR_ILLEGAL_VALUE;
&& aVersion != nsISOAPMessage::VERSION_1_2)
return NS_ERROR_ILLEGAL_VALUE;
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMNode > ignored;
nsCOMPtr < nsIDOMParser > parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString docstr;
rv = parser->ParseFromString(nsString(*kEmptySOAPDocStr[aVersion]).get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
rv = parser->ParseFromString(nsString(*kEmptySOAPDocStr[aVersion]).get(),
"text/xml", getter_AddRefs(mMessage));
if (NS_FAILED(rv))
return rv;
// Declare the default encoding. This should always be non-null, but may be empty string.
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (encoding) {
nsCOMPtr<nsIDOMElement> envelope;
nsCOMPtr < nsIDOMElement > envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (envelope) {
nsAutoString enc;
rv = mEncoding->GetStyleURI(enc);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!enc.IsEmpty()) {
rv = envelope->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
if (NS_FAILED(rv)) return rv;
rv = envelope->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::
kEncodingStyleAttribute, enc);
if (NS_FAILED(rv))
return rv;
}
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
nsCOMPtr < nsIDOMElement > parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISupports > next;
nsCOMPtr < nsISOAPHeaderBlock > header;
nsCOMPtr < nsIDOMElement > element;
nsCOMPtr < nsISchemaType > schemaType;
nsCOMPtr < nsIVariant > value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
PRBool mustUnderstand;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
if (!header)
return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMNode > node1 = (nsIDOMElement *) element;
nsCOMPtr < nsIDOMNode > node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv))
return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv))
return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetMustUnderstand(&mustUnderstand);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
} else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv))
return rv;
rv = header->GetName(name);
if (NS_FAILED(rv))
return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv))
return rv;
rv = header->GetMustUnderstand(&mustUnderstand);
if (NS_FAILED(rv))
return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv))
return rv;
if (!encoding) {
rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
if (NS_FAILED(rv)) return rv;
}
if (mustUnderstand) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kMustUnderstandAttribute, nsSOAPUtils::kTrueA);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv))
return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv))
return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent,
getter_AddRefs(element));
if (NS_FAILED(rv))
return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::kActorAttribute, actorURI);
if (NS_FAILED(rv))
return rv;
}
if (mustUnderstand) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::
kMustUnderstandAttribute,
nsSOAPUtils::kTrueA);
if (NS_FAILED(rv))
return rv;
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->
SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr < nsIDOMElement > call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName,
getter_AddRefs(call));
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMNode > ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefix(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> newencoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsCOMPtr < nsISupports > next;
nsCOMPtr < nsISOAPParameter > param;
nsCOMPtr < nsIDOMElement > element;
nsCOMPtr < nsISOAPEncoding > newencoding;
nsCOMPtr < nsISchemaType > schemaType;
nsCOMPtr < nsIVariant > value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
if (!param)
return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
nsCOMPtr < nsIDOMNode > node1 = (nsIDOMElement *) element;
nsCOMPtr < nsIDOMNode > node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
element = do_QueryInterface(node1);
}
else {
} else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetEncoding(getter_AddRefs(newencoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!newencoding) {
newencoding = encoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = newencoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
schemaType, nsnull, body,
getter_AddRefs(element));
if (NS_FAILED(rv))
return rv;
if (encoding != newencoding) {
nsAutoString enc;
newencoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
nsAutoString enc;
newencoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
@ -427,44 +495,53 @@ static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
* found a starting point, so it is used but not checked again. We
* also know that since there is a version, there is an encoding.
*/
nsresult nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement* aFirst, PRUint16 *aVersion, nsISOAPEncoding **aEncoding)
nsresult
nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement * aFirst,
PRUint16 * aVersion,
nsISOAPEncoding ** aEncoding)
{
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
nsresult rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = GetVersion(aVersion);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> element = aFirst;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMElement > element = aFirst;
// Check for stray encodingStyle attributes. If none found, then use empty string encoding style.
nsAutoString style;
for (;;) {
nsCOMPtr<nsIDOMAttr> enc;
rv = element->GetAttributeNodeNS(*nsSOAPUtils::kSOAPEncURI[*aVersion], nsSOAPUtils::kEncodingStyleAttribute, getter_AddRefs(enc));
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMAttr > enc;
rv = element->GetAttributeNodeNS(*nsSOAPUtils::kSOAPEncURI[*aVersion],
nsSOAPUtils::kEncodingStyleAttribute,
getter_AddRefs(enc));
if (NS_FAILED(rv))
return rv;
if (enc) {
rv = enc->GetNodeValue(style);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
break;
}
else {
nsCOMPtr<nsIDOMNode>next;
} else {
nsCOMPtr < nsIDOMNode > next;
rv = element->GetParentNode(getter_AddRefs(next));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (next) {
PRUint16 type;
rv = element->GetNodeType(&type);
if (NS_FAILED(rv)) return rv;
PRUint16 type;
rv = element->GetNodeType(&type);
if (NS_FAILED(rv))
return rv;
if (type != nsIDOMNode::ELEMENT_NODE) {
next = nsnull;
next = nsnull;
}
}
if (next) {
element = do_QueryInterface(next);
}
else {
break;
} else {
break;
}
}
}
@ -472,33 +549,41 @@ nsresult nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement* aFirst, PRUint16 *
}
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
NS_IMETHODIMP
nsSOAPMessage::GetHeaderBlocks(PRUint32 * aCount,
nsISOAPHeaderBlock *** aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
nsCOMPtr < nsIMemory > memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr < nsIDOMElement > element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv) || !element) return rv;
nsCOMPtr<nsISOAPEncoding> encoding;
if (NS_FAILED(rv) || !element)
return rv;
nsCOMPtr < nsISOAPEncoding > encoding;
PRUint16 version;
rv = GetEncodingWithVersion(element, &version, getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMElement > next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr < nsISOAPHeaderBlock > header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
*aHeaderBlocks =
(nsISOAPHeaderBlock * *)memory->Realloc(*aHeaderBlocks,
length *
sizeof(**aHeaderBlocks));
}
element = next;
header = do_CreateInstance(NS_SOAPHEADERBLOCK_CONTRACTID);
if (!header) return NS_ERROR_OUT_OF_MEMORY;
if (!header)
return NS_ERROR_OUT_OF_MEMORY;
header->Init(nsnull, version);
(*aHeaderBlocks)[(*aCount)] = header;
@ -506,86 +591,111 @@ NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBloc
(*aCount)++;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = header->SetEncoding(encoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
*aHeaderBlocks =
(nsISOAPHeaderBlock * *)memory->Realloc(*aHeaderBlocks,
(*aCount) *
sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
NS_IMETHODIMP
nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 * aCount,
nsISOAPParameter *** aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
nsCOMPtr < nsIMemory > memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr < nsIDOMElement > element;
nsresult rv = GetBody(getter_AddRefs(element));
if (NS_FAILED(rv) || !element) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
if (NS_FAILED(rv) || !element)
return rv;
nsCOMPtr < nsIDOMElement > next;
nsCOMPtr < nsISOAPParameter > param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
if (!aDocumentStyle) {
element = next;
if (!element) return NS_ERROR_ILLEGAL_VALUE;
if (!element)
return NS_ERROR_ILLEGAL_VALUE;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
}
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
PRUint16 version;
rv = GetEncodingWithVersion(element, &version, getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
*aParameters =
(nsISOAPParameter * *)memory->Realloc(*aParameters,
length *
sizeof(**aParameters));
}
element = next;
param = do_CreateInstance(NS_SOAPPARAMETER_CONTRACTID);
if (!param) return NS_ERROR_OUT_OF_MEMORY;
if (!param)
return NS_ERROR_OUT_OF_MEMORY;
(*aParameters)[(*aCount)] = param;
NS_ADDREF((*aParameters)[(*aCount)]);
(*aCount)++;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->SetEncoding(encoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
*aParameters =
(nsISOAPParameter * *)memory->Realloc(*aParameters,
(*aCount) *
sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding * *aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
PRUint16 version;
nsresult rc = GetVersion(&version);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (version != nsISOAPMessage::VERSION_UNKNOWN) {
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
nsCOMPtr < nsISOAPEncoding > encoding =
do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
if (!encoding)
return NS_ERROR_OUT_OF_MEMORY;
rc = encoding->GetAssociatedEncoding(*nsSOAPUtils::kSOAPEncURI[version], PR_FALSE, getter_AddRefs(mEncoding));
if (NS_FAILED(rc)) return rc;
return NS_ERROR_OUT_OF_MEMORY;
rc = encoding->
GetAssociatedEncoding(*nsSOAPUtils::kSOAPEncURI[version],
PR_FALSE, getter_AddRefs(mEncoding));
if (NS_FAILED(rc))
return rc;
}
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding * aEncoding)
{
mEncoding = aEncoding;
return NS_OK;

View File

@ -32,23 +32,21 @@
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage
{
class nsSOAPMessage:public nsISOAPMessage {
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
virtual ~ nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
protected:
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE protected:
PRUint16 GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope);
nsresult GetEncodingWithVersion(nsIDOMElement *aFirst, PRUint16 *aVersion, nsISOAPEncoding **aEncoding);
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsresult GetEncodingWithVersion(nsIDOMElement * aFirst,
PRUint16 * aVersion,
nsISOAPEncoding ** aEncoding);
nsCOMPtr < nsIDOMDocument > mMessage;
nsCOMPtr < nsISOAPEncoding > mEncoding;
nsString mActionURI;
};

View File

@ -32,15 +32,14 @@ nsSOAPParameter::nsSOAPParameter()
NS_INIT_ISUPPORTS();
}
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_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()
nsSOAPParameter::~nsSOAPParameter()
{
}

View File

@ -34,19 +34,13 @@
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPParameter : public nsSOAPBlock,
public nsISOAPParameter
{
class nsSOAPParameter:public nsSOAPBlock, public nsISOAPParameter {
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
virtual ~ nsSOAPParameter();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
};
NS_DECL_ISUPPORTS NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER};
#endif

View File

@ -0,0 +1,271 @@
/* -*- 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) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsSOAPPropertyBag.h"
#include "nsIXPConnect.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsSupportsArray.h"
#include "nsHashtable.h"
#include "jsapi.h"
#include "nsIXPCScriptable.h"
class nsSOAPPropertyBagEnumerator;
class nsSOAPPropertyBag:public nsIPropertyBag, public nsIXPCScriptable {
public:
nsSOAPPropertyBag();
virtual ~ nsSOAPPropertyBag();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROPERTYBAG
NS_DECL_NSIXPCSCRIPTABLE
nsresult SetProperty(const nsAString & aName, nsIVariant * aValue);
protected:
nsSupportsHashtable * mProperties;
friend nsSOAPPropertyBagEnumerator;
};
class nsSOAPProperty:public nsIProperty {
public:
nsSOAPProperty(const nsAString & aName, nsIVariant * aValue);
virtual ~ nsSOAPProperty();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROPERTY
protected:
nsString mName;
nsCOMPtr < nsIVariant > mValue;
};
class nsSOAPPropertyBagEnumerator:public nsISimpleEnumerator {
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsSOAPPropertyBagEnumerator methods:
nsSOAPPropertyBagEnumerator(nsSOAPPropertyBag * aPropertyBag);
virtual ~nsSOAPPropertyBagEnumerator();
protected:
nsCOMPtr < nsSupportsArray > mProperties;
PRUint32 mCurrent;
};
NS_IMPL_ISUPPORTS2_CI(nsSOAPPropertyBag, nsIPropertyBag, nsIXPCScriptable)
nsSOAPPropertyBag::nsSOAPPropertyBag():mProperties(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* property initializers and constructor code */
}
nsSOAPPropertyBag::~nsSOAPPropertyBag()
{
/* destructor code */
delete mProperties;
}
/* nsIVariant getProperty (in AString name); */
NS_IMETHODIMP
nsSOAPPropertyBag::GetProperty(const nsAString & aName,
nsIVariant ** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aName);
*_retval = NS_STATIC_CAST(nsIVariant *, mProperties->Get(&nameKey));
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBag::SetProperty(const nsAString & aName,
nsIVariant * aValue)
{
NS_ENSURE_ARG_POINTER(&aName);
NS_ENSURE_ARG_POINTER(aValue);
nsStringKey nameKey(aName);
return mProperties->Put(&nameKey, aValue);
}
// The nsIXPCScriptable map declaration that will generate stubs for us...
#define XPC_MAP_CLASSNAME nsSOAPPropertyBag
#define XPC_MAP_QUOTED_CLASSNAME "SOAPPropertyBag"
#define XPC_MAP_WANT_SETPROPERTY
#define XPC_MAP_WANT_GETPROPERTY
#define XPC_MAP_FLAGS nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
#include "xpc_map_end.h" /* This will #undef the above */
NS_IMETHODIMP
nsSOAPPropertyBag::GetProperty(nsIXPConnectWrappedNative * wrapper,
JSContext * cx, JSObject * obj,
jsval id, jsval * vp, PRBool * _retval)
{
if (JSVAL_IS_STRING(id)) {
JSString *str = JSVAL_TO_STRING(id);
const PRUnichar *name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr < nsIVariant > value =
dont_AddRef(NS_STATIC_CAST
(nsIVariant *, mProperties->Get(&nameKey)));
if (value == nsnull)
return NS_OK;
void *mark;
jsval *argv = JS_PushArguments(cx, &mark, "/%iv", value.get());
*vp = *argv;
JS_PopArguments(cx, mark);
}
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBag::SetProperty(nsIXPConnectWrappedNative * wrapper,
JSContext * cx, JSObject * obj,
jsval id, jsval * vp, PRBool * _retval)
{
if (JSVAL_IS_STRING(id)) {
JSString *str = JSVAL_TO_STRING(id);
const PRUnichar *name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr < nsIVariant > value; // Call to convert to variant.
if (!JS_ConvertArguments(cx, 1, vp, "/%iv", getter_AddRefs(value)))
return NS_ERROR_ILLEGAL_VALUE;
mProperties->Put(&nameKey, value);
}
return NS_OK;
}
PRBool PropertyBagEnumFunc(nsHashKey * aKey, void *aData, void *aClosure)
{
nsISupportsArray *properties =
NS_STATIC_CAST(nsISupportsArray *, aClosure);
nsAutoString name(NS_STATIC_CAST(nsStringKey *, aKey)->GetString());
properties->
AppendElement(new
nsSOAPProperty(name,
NS_STATIC_CAST(nsIVariant *, aData)));
return PR_TRUE;
}
nsSOAPPropertyBagEnumerator::nsSOAPPropertyBagEnumerator(nsSOAPPropertyBag * aPropertyBag):mProperties(new nsSupportsArray()),
mCurrent
(0)
{
NS_INIT_REFCNT();
aPropertyBag->mProperties->Enumerate(&PropertyBagEnumFunc, mProperties);
}
nsSOAPPropertyBagEnumerator::~nsSOAPPropertyBagEnumerator()
{
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPPropertyBagEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP nsSOAPPropertyBagEnumerator::GetNext(nsISupports ** aItem)
{
NS_ENSURE_ARG_POINTER(aItem);
PRUint32 count;
mProperties->Count(&count);
if (mCurrent < count) {
*aItem = mProperties->ElementAt(mCurrent++);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSOAPPropertyBagEnumerator::HasMoreElements(PRBool * aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
PRUint32 count;
mProperties->Count(&count);
*aResult = mCurrent < count;
return NS_OK;
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPProperty, nsIProperty)
nsSOAPProperty::nsSOAPProperty(const nsAString & aName,
nsIVariant * aValue):mName(aName), mValue(aValue) {
NS_INIT_REFCNT();
}
nsSOAPProperty::~nsSOAPProperty()
{
}
NS_IMETHODIMP nsSOAPProperty::GetName(nsAString & _retval) {
NS_ENSURE_ARG_POINTER(&_retval);
_retval.Assign(mName);
return NS_OK;
}
NS_IMETHODIMP nsSOAPProperty::GetValue(nsIVariant** _retval) {
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mValue;
NS_ADDREF(*_retval);
return NS_OK;
}
/* readonly attribute nsISimpleEnumerator enumerator; */
NS_IMETHODIMP
nsSOAPPropertyBag::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
{
NS_ENSURE_ARG_POINTER(aEnumerator);
*aEnumerator = new nsSOAPPropertyBagEnumerator(this);
if (aEnumerator) {
NS_ADDREF(*aEnumerator);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
}
nsSOAPPropertyBagMutator::nsSOAPPropertyBagMutator()
{
NS_INIT_REFCNT();
mBag = mSOAPBag = new nsSOAPPropertyBag();
}
nsSOAPPropertyBagMutator::~nsSOAPPropertyBagMutator()
{
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPPropertyBagMutator, nsISOAPPropertyBagMutator)
NS_IMETHODIMP nsSOAPPropertyBagMutator::GetPropertyBag(nsIPropertyBag ** aPropertyBag) {
NS_ENSURE_ARG_POINTER(aPropertyBag);
*aPropertyBag = mBag;
NS_ADDREF(*aPropertyBag);
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBagMutator::AddProperty(const nsAString & aName,
nsIVariant * aValue)
{
NS_ENSURE_ARG_POINTER(&aName);
NS_ENSURE_ARG_POINTER(aValue);
return mSOAPBag->SetProperty(aName, aValue);
}

View File

@ -0,0 +1,64 @@
/* -*- 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) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPPropertyBag_h__
#define nsSOAPPropertyBag_h__
#include "nsString.h"
#include "nsIPropertyBag.h"
#include "nsISOAPPropertyBagMutator.h"
#include "nsCOMPtr.h"
#include "nsIXPCScriptable.h"
#include "nsHashtable.h"
#include "nsSupportsArray.h"
class nsSOAPPropertyBag;
class nsSOAPPropertyBagMutator:public nsISOAPPropertyBagMutator {
public:
nsSOAPPropertyBagMutator();
virtual ~nsSOAPPropertyBagMutator();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPPROPERTYBAGMUTATOR
protected:
nsCOMPtr<nsIPropertyBag> mBag;
nsSOAPPropertyBag* mSOAPBag;
};
#define NS_SOAPPROPERTY_CID \
{ /* 147d8bfe-1dd2-11b2-b72e-bba9d7a0dab7 */ \
0x147d8bfe, 0x1dd2, 0x11b2, \
{0xb7, 0x2e, 0xbb, 0xa9, 0xd7, 0xa0, 0xda, 0xb7} }
#define NS_SOAPPROPERTY_CONTRACTID "@mozilla.org/xmlextras/soap/property;1"
#define NS_SOAPPROPERTYBAG_CID \
{ /* 205621ac-1dd2-11b2-8c86-ede3fe564ef1 */ \
0x205621ac, 0x1dd2, 0x11b2, \
{0x8c, 0x86, 0xed, 0xe3, 0xfe, 0x56, 0x4e, 0xf1} }
#define NS_SOAPPROPERTYBAG_CONTRACTID "@mozilla.org/xmlextras/soap/property/bag;1"
#define NS_SOAPPROPERTYBAGENUMERATOR_CID \
{ /* 34e1f484-1dd2-11b2-a8c0-f20a9f3a0c55 */ \
0x34e1f484, 0x1dd2, 0x11b2, \
{0xa8, 0xc0, 0xf2, 0x0a, 0x9f, 0x3a, 0x0c, 0x55} }
#define NS_SOAPPROPERTYBAGENUMERATOR_CONTRACTID "@mozilla.org/xmlextras/soap/property/bag/enumerator;1"
#endif

View File

@ -38,46 +38,49 @@ nsSOAPResponse::~nsSOAPResponse()
/* destructor code */
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPResponse, nsISOAPMessage, nsISOAPResponse)
NS_IMPL_ADDREF_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPResponse)
NS_INTERFACE_MAP_ENTRY(nsISOAPResponse)
NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPResponse, nsISOAPMessage,
nsISOAPResponse)
NS_IMPL_ADDREF_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPResponse)
NS_INTERFACE_MAP_ENTRY(nsISOAPResponse)
NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
*aFault = nsnull;
nsresult rc = GetBody(getter_AddRefs(body));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (body) {
PRUint16 version;
rc = GetVersion(&version);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (rc != nsSOAPMessage::VERSION_UNKNOWN) {
nsCOMPtr<nsIDOMElement> fault;
nsSOAPUtils::GetSpecificChildElement(body,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kFaultTagName,
getter_AddRefs(fault));
nsCOMPtr < nsIDOMElement > fault;
nsSOAPUtils::GetSpecificChildElement(body,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kFaultTagName,
getter_AddRefs(fault));
if (fault) {
nsCOMPtr<nsISOAPFault> f = do_CreateInstance(NS_SOAPFAULT_CONTRACTID);
if (!f)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr < nsISOAPFault > f =
do_CreateInstance(NS_SOAPFAULT_CONTRACTID);
if (!f)
return NS_ERROR_OUT_OF_MEMORY;
rc = f->SetElement(fault);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
*aFault = f;
NS_ADDREF(*aFault);
NS_ADDREF(*aFault);
}
}
}
else {
} else {
*aFault = nsnull;
}
return NS_OK;

View File

@ -30,20 +30,14 @@
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
class nsSOAPResponse:public nsSOAPMessage, public nsISOAPResponse {
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
nsSOAPResponse();
virtual ~nsSOAPResponse();
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE nsSOAPResponse();
virtual ~ nsSOAPResponse();
protected:
};

View File

@ -26,126 +26,144 @@
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(realSOAPEnvURI1,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(realSOAPEnvURI2,"http://www.w3.org/2001/09/soap-envelope");
const nsAString* nsSOAPUtils::kSOAPEnvURI[] = {&realSOAPEnvURI1, &realSOAPEnvURI2};
NS_NAMED_LITERAL_STRING(realSOAPEnvURI1,
"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(realSOAPEnvURI2,
"http://www.w3.org/2001/09/soap-envelope");
const nsAString *nsSOAPUtils::kSOAPEnvURI[] =
{ &realSOAPEnvURI1, &realSOAPEnvURI2
};
NS_NAMED_LITERAL_STRING(realSOAPEncURI1,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(realSOAPEncURI2,"http://www.w3.org/2001/09/soap-encoding");
const nsAString* nsSOAPUtils::kSOAPEncURI[] = {&realSOAPEncURI1, &realSOAPEncURI2};
NS_NAMED_LITERAL_STRING(realSOAPEncURI1,
"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(realSOAPEncURI2,
"http://www.w3.org/2001/09/soap-encoding");
const nsAString *nsSOAPUtils::kSOAPEncURI[] =
{ &realSOAPEncURI1, &realSOAPEncURI2
};
NS_NAMED_LITERAL_STRING(realXSIURI1,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(realXSIURI2,"http://www.w3.org/2001/XMLSchema-instance");
const nsAString* nsSOAPUtils::kXSIURI[] = {&realXSIURI1, &realXSIURI2};
NS_NAMED_LITERAL_STRING(realXSIURI1,
"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(realXSIURI2,
"http://www.w3.org/2001/XMLSchema-instance");
const nsAString *nsSOAPUtils::kXSIURI[] = { &realXSIURI1, &realXSIURI2
};
NS_NAMED_LITERAL_STRING(realXSURI1,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(realXSURI2,"http://www.w3.org/2001/XMLSchema");
const nsAString* nsSOAPUtils::kXSURI[] = {&realXSURI1, &realXSURI2};
NS_NAMED_LITERAL_STRING(realXSURI1, "http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(realXSURI2, "http://www.w3.org/2001/XMLSchema");
const nsAString *nsSOAPUtils::kXSURI[] = { &realXSURI1, &realXSURI2
};
NS_NAMED_LITERAL_STRING(realSOAPEnvPrefix,"env");
const nsAString& nsSOAPUtils::kSOAPEnvPrefix = realSOAPEnvPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEnvPrefix, "env");
const nsAString & nsSOAPUtils::kSOAPEnvPrefix = realSOAPEnvPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEncPrefix,"enc");
const nsAString& nsSOAPUtils::kSOAPEncPrefix = realSOAPEncPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEncPrefix, "enc");
const nsAString & nsSOAPUtils::kSOAPEncPrefix = realSOAPEncPrefix;
NS_NAMED_LITERAL_STRING(realXSIPrefix,"xsi");
const nsAString& nsSOAPUtils::kXSIPrefix = realXSIPrefix;
NS_NAMED_LITERAL_STRING(realXSIPrefix, "xsi");
const nsAString & nsSOAPUtils::kXSIPrefix = realXSIPrefix;
NS_NAMED_LITERAL_STRING(realXSITypeAttribute,"type");
const nsAString& nsSOAPUtils::kXSITypeAttribute = realXSITypeAttribute;
NS_NAMED_LITERAL_STRING(realXSITypeAttribute, "type");
const nsAString & nsSOAPUtils::kXSITypeAttribute = realXSITypeAttribute;
NS_NAMED_LITERAL_STRING(realXSPrefix,"xs");
const nsAString& nsSOAPUtils::kXSPrefix = realXSPrefix;
NS_NAMED_LITERAL_STRING(realXSPrefix, "xs");
const nsAString & nsSOAPUtils::kXSPrefix = realXSPrefix;
NS_NAMED_LITERAL_STRING(realEncodingStyleAttribute,"encodingStyle");
const nsAString& nsSOAPUtils::kEncodingStyleAttribute = realEncodingStyleAttribute;
NS_NAMED_LITERAL_STRING(realEncodingStyleAttribute, "encodingStyle");
const
nsAString &
nsSOAPUtils::kEncodingStyleAttribute = realEncodingStyleAttribute;
NS_NAMED_LITERAL_STRING(realActorAttribute,"actor");
const nsAString& nsSOAPUtils::kActorAttribute = realActorAttribute;
NS_NAMED_LITERAL_STRING(realActorAttribute, "actor");
const nsAString & nsSOAPUtils::kActorAttribute = realActorAttribute;
NS_NAMED_LITERAL_STRING(realMustUnderstandAttribute,"mustUnderstand");
const nsAString& nsSOAPUtils::kMustUnderstandAttribute = realMustUnderstandAttribute;
NS_NAMED_LITERAL_STRING(realMustUnderstandAttribute, "mustUnderstand");
const
nsAString &
nsSOAPUtils::kMustUnderstandAttribute = realMustUnderstandAttribute;
NS_NAMED_LITERAL_STRING(realEnvelopeTagName,"Envelope");
const nsAString& nsSOAPUtils::kEnvelopeTagName = realEnvelopeTagName;
NS_NAMED_LITERAL_STRING(realEnvelopeTagName, "Envelope");
const nsAString & nsSOAPUtils::kEnvelopeTagName = realEnvelopeTagName;
NS_NAMED_LITERAL_STRING(realHeaderTagName,"Header");
const nsAString& nsSOAPUtils::kHeaderTagName = realHeaderTagName;
NS_NAMED_LITERAL_STRING(realHeaderTagName, "Header");
const nsAString & nsSOAPUtils::kHeaderTagName = realHeaderTagName;
NS_NAMED_LITERAL_STRING(realBodyTagName,"Body");
const nsAString& nsSOAPUtils::kBodyTagName = realBodyTagName;
NS_NAMED_LITERAL_STRING(realBodyTagName, "Body");
const nsAString & nsSOAPUtils::kBodyTagName = realBodyTagName;
NS_NAMED_LITERAL_STRING(realFaultTagName,"Fault");
const nsAString& nsSOAPUtils::kFaultTagName = realFaultTagName;
NS_NAMED_LITERAL_STRING(realFaultTagName, "Fault");
const nsAString & nsSOAPUtils::kFaultTagName = realFaultTagName;
NS_NAMED_LITERAL_STRING(realFaultCodeTagName,"faultcode");
const nsAString& nsSOAPUtils::kFaultCodeTagName = realFaultCodeTagName;
NS_NAMED_LITERAL_STRING(realFaultCodeTagName, "faultcode");
const nsAString & nsSOAPUtils::kFaultCodeTagName = realFaultCodeTagName;
NS_NAMED_LITERAL_STRING(realFaultStringTagName,"faultstring");
const nsAString& nsSOAPUtils::kFaultStringTagName = realFaultStringTagName;
NS_NAMED_LITERAL_STRING(realFaultStringTagName, "faultstring");
const
nsAString & nsSOAPUtils::kFaultStringTagName = realFaultStringTagName;
NS_NAMED_LITERAL_STRING(realFaultActorTagName,"faultactor");
const nsAString& nsSOAPUtils::kFaultActorTagName = realFaultActorTagName;
NS_NAMED_LITERAL_STRING(realFaultActorTagName, "faultactor");
const nsAString & nsSOAPUtils::kFaultActorTagName = realFaultActorTagName;
NS_NAMED_LITERAL_STRING(realFaultDetailTagName,"detail");
const nsAString& nsSOAPUtils::kFaultDetailTagName = realFaultDetailTagName;
NS_NAMED_LITERAL_STRING(realFaultDetailTagName, "detail");
const
nsAString & nsSOAPUtils::kFaultDetailTagName = realFaultDetailTagName;
NS_NAMED_LITERAL_STRING(realEncodingSeparator,"#");
const nsAString& nsSOAPUtils::kEncodingSeparator = realEncodingSeparator;
NS_NAMED_LITERAL_STRING(realEncodingSeparator, "#");
const nsAString & nsSOAPUtils::kEncodingSeparator = realEncodingSeparator;
NS_NAMED_LITERAL_STRING(realQualifiedSeparator,":");
const nsAString& nsSOAPUtils::kQualifiedSeparator = realQualifiedSeparator;
NS_NAMED_LITERAL_STRING(realQualifiedSeparator, ":");
const
nsAString & nsSOAPUtils::kQualifiedSeparator = realQualifiedSeparator;
NS_NAMED_LITERAL_STRING(realXMLNamespaceNamespaceURI, "http://www.w3.org/2000/xmlns/");
const nsAString& nsSOAPUtils::kXMLNamespaceNamespaceURI = realXMLNamespaceNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceNamespaceURI,
"http://www.w3.org/2000/xmlns/");
const nsAString &
nsSOAPUtils::kXMLNamespaceNamespaceURI = realXMLNamespaceNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceURI, "http://www.w3.org/XML/1998/namespace");
const nsAString& nsSOAPUtils::kXMLNamespaceURI = realXMLNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceURI,
"http://www.w3.org/XML/1998/namespace");
const
nsAString & nsSOAPUtils::kXMLNamespaceURI = realXMLNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLPrefix, "xml:");
const nsAString& nsSOAPUtils::kXMLPrefix = realXMLPrefix;
const nsAString & nsSOAPUtils::kXMLPrefix = realXMLPrefix;
NS_NAMED_LITERAL_STRING(realXMLNamespacePrefix, "xmlns:");
const nsAString& nsSOAPUtils::kXMLNamespacePrefix = realXMLNamespacePrefix;
const
nsAString & nsSOAPUtils::kXMLNamespacePrefix = realXMLNamespacePrefix;
NS_NAMED_LITERAL_STRING(realTrue, "true");
const nsAString& nsSOAPUtils::kTrue = realTrue;
const nsAString & nsSOAPUtils::kTrue = realTrue;
NS_NAMED_LITERAL_STRING(realFalse, "false");
const nsAString& nsSOAPUtils::kFalse = realFalse;
const nsAString & nsSOAPUtils::kFalse = realFalse;
NS_NAMED_LITERAL_STRING(realTrueA, "1");
const nsAString& nsSOAPUtils::kTrueA = realTrueA;
const nsAString & nsSOAPUtils::kTrueA = realTrueA;
NS_NAMED_LITERAL_STRING(realFalseA, "0");
const nsAString& nsSOAPUtils::kFalseA = realFalseA;
const nsAString & nsSOAPUtils::kFalseA = realFalseA;
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement)
void nsSOAPUtils::GetSpecificChildElement(nsIDOMElement * aParent,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
nsCOMPtr < nsIDOMElement > sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
if (sibling) {
GetSpecificSiblingElement(sibling, aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement)
void nsSOAPUtils::GetSpecificSiblingElement(nsIDOMElement * aSibling,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
nsCOMPtr < nsIDOMElement > sibling;
*aElement = nsnull;
sibling = aSibling;
@ -153,23 +171,21 @@ nsSOAPUtils::GetSpecificSiblingElement(
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(aNamespace))
{
if (name.Equals(aType) && namespaceURI.Equals(aNamespace)) {
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
nsCOMPtr < nsIDOMElement > temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
void nsSOAPUtils::GetFirstChildElement(nsIDOMElement * aParent,
nsIDOMElement ** aElement)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
@ -177,19 +193,18 @@ nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void **) aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
void nsSOAPUtils::GetNextSiblingElement(nsIDOMElement * aStart,
nsIDOMElement ** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
nsCOMPtr < nsIDOMNode > sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
@ -197,45 +212,44 @@ nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
sibling->QueryInterface(NS_GET_IID(nsIDOMElement),
(void **) aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
nsCOMPtr < nsIDOMNode > temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAString& aText)
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement * aElement,
nsAString & aText)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr < nsIDOMText > text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
} else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
PRBool nsSOAPUtils::HasChildElements(nsIDOMElement * aElement)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
@ -244,18 +258,18 @@ nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
void nsSOAPUtils::GetNextSibling(nsIDOMNode * aSibling,
nsIDOMNode ** aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
nsCOMPtr < nsIDOMNode > last;
nsCOMPtr < nsIDOMNode > current;
PRUint16 type;
*aNext = nsnull;
@ -264,23 +278,19 @@ nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
if (!last) {
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
} else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
while (!current) {
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
} else {
current = nsnull;
break;
}
@ -288,9 +298,11 @@ nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAString & aQName,
nsAString & aURI)
nsresult
nsSOAPUtils::GetNamespaceURI(nsIDOMElement * aScope,
const nsAString & aQName,
nsAString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
@ -306,41 +318,46 @@ nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsCOMPtr < nsIDOMNode > current = aScope;
nsCOMPtr < nsIDOMNamedNodeMap > attrs;
nsCOMPtr < nsIDOMNode > temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix,
getter_AddRefs(temp));
if (NS_FAILED(rc))
return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAString & aQName,
nsAString & aLocalName)
nsresult
nsSOAPUtils::GetLocalName(const nsAString & aQName,
nsAString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i+1, aQName.Length() - i);
aQName.Mid(aLocalName, i + 1, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAString & aURI,
nsAString & aPrefix)
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement * aScope,
const nsAString & aURI,
nsAString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
@ -351,60 +368,65 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsCOMPtr < nsIDOMNode > current = aScope;
nsCOMPtr < nsIDOMNamedNodeMap > attrs;
nsCOMPtr < nsIDOMNode > temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
for (;;) {
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc))
return rc;
nsCOMPtr < nsIDOMNode > check = aScope;
PRBool hasDecl;
nsCOMPtr < nsIDOMElement > echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
rc = echeck->
HasAttributeNS(nsSOAPUtils::
kXMLNamespaceNamespaceURI, prefix,
&hasDecl);
if (NS_FAILED(rc))
return rc;
if (hasDecl)
break;
echeck->GetParentNode(getter_AddRefs(check));
break;
echeck->GetParentNode(getter_AddRefs(check));
}
}
if (check == current) {
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
else { // Decode the generated namespace into a number
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
@ -418,7 +440,7 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
maxns = n;
}
}
}
@ -437,14 +459,14 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
nsWritingIterator < PRUnichar > i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
*i2 = (PRUnichar) (r + '0');
}
i2--;
*i2 = 's';
@ -453,22 +475,23 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAString& aSuper,
nsAString& aSub)
PRBool nsSOAPUtils::StartsWith(nsAString & aSuper, nsAString & aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
if (c1 < c2)
return PR_FALSE;
if (c1 == c2)
return aSuper.Equals(aSub);
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
if (*i1 != *i2)
return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@ -28,79 +28,77 @@
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetSpecificChildElement(nsIDOMElement * aParent,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement * aSibling,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement * aParent,
nsIDOMElement ** aElement);
static void GetNextSiblingElement(nsIDOMElement * aStart,
nsIDOMElement ** aElement);
static nsresult GetElementTextContent(nsIDOMElement * aElement,
nsAString & aText);
static PRBool HasChildElements(nsIDOMElement * aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAString & aURI,
nsAString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAString & aQName,
nsAString & aURI);
static nsresult GetLocalName(const nsAString & aQName,
nsAString & aLocalName);
static void GetNextSibling(nsIDOMNode * aSibling, nsIDOMNode ** aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement * aElement,
const nsAString & aURI,
nsAString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement * aElement,
const nsAString & aQName,
nsAString & aURI);
static nsresult GetLocalName(const nsAString & aQName,
nsAString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAString& aSuper,
nsAString& aSub);
static const nsAString* kSOAPEnvURI[];
static const nsAString* kSOAPEncURI[];
static const nsAString* kXSIURI[];
static const nsAString* kXSURI[];
static PRBool StartsWith(nsAString & aSuper, nsAString & aSub);
static const nsAString& kSOAPEnvPrefix;
static const nsAString& kSOAPEncPrefix;
static const nsAString& kXSIPrefix;
static const nsAString& kXSITypeAttribute;
static const nsAString& kXSPrefix;
static const nsAString& kEncodingStyleAttribute;
static const nsAString& kActorAttribute;
static const nsAString& kMustUnderstandAttribute;
static const nsAString& kEnvelopeTagName;
static const nsAString& kHeaderTagName;
static const nsAString& kBodyTagName;
static const nsAString& kFaultTagName;
static const nsAString& kFaultCodeTagName;
static const nsAString& kFaultStringTagName;
static const nsAString& kFaultActorTagName;
static const nsAString& kFaultDetailTagName;
static const nsAString& kEncodingSeparator;
static const nsAString& kQualifiedSeparator;
static const nsAString& kXMLNamespaceNamespaceURI;
static const nsAString& kXMLNamespaceURI;
static const nsAString& kXMLNamespacePrefix;
static const nsAString& kXMLPrefix;
static const nsAString& kTrue;
static const nsAString& kTrueA;
static const nsAString& kFalse;
static const nsAString& kFalseA;
} ;
static const nsAString *kSOAPEnvURI[];
static const nsAString *kSOAPEncURI[];
static const nsAString *kXSIURI[];
static const nsAString *kXSURI[];
static const nsAString & kSOAPEnvPrefix;
static const nsAString & kSOAPEncPrefix;
static const nsAString & kXSIPrefix;
static const nsAString & kXSITypeAttribute;
static const nsAString & kXSPrefix;
static const nsAString & kEncodingStyleAttribute;
static const nsAString & kActorAttribute;
static const nsAString & kMustUnderstandAttribute;
static const nsAString & kEnvelopeTagName;
static const nsAString & kHeaderTagName;
static const nsAString & kBodyTagName;
static const nsAString & kFaultTagName;
static const nsAString & kFaultCodeTagName;
static const nsAString & kFaultStringTagName;
static const nsAString & kFaultActorTagName;
static const nsAString & kFaultDetailTagName;
static const nsAString & kEncodingSeparator;
static const nsAString & kQualifiedSeparator;
static const nsAString & kXMLNamespaceNamespaceURI;
static const nsAString & kXMLNamespaceURI;
static const nsAString & kXMLNamespacePrefix;
static const nsAString & kXMLPrefix;
static const nsAString & kTrue;
static const nsAString & kTrueA;
static const nsAString & kFalse;
static const nsAString & kFalseA;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAString& aString)
inline PRBool AStringIsNull(const nsAString & aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAString& aString)
inline void SetAStringToNull(nsAString & aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
@ -109,7 +107,9 @@ inline void SetAStringToNull(nsAString& aString)
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
inline void SOAPEncodingKey(const nsAString& aURI, const nsAString& aType, nsAString& result)
inline void
SOAPEncodingKey(const nsAString & aURI, const nsAString & aType,
nsAString & result)
{
result.Assign(aURI);
result.Append(nsSOAPUtils::kEncodingSeparator);

View File

@ -44,6 +44,7 @@ REQUIRES = xpcom \
necko \
webbrwsr \
embedcomponents \
xpconnect \
$(NULL)
CPPSRCS = nsXMLExtrasModule.cpp

View File

@ -59,6 +59,7 @@
#include "nsSOAPFault.h"
#include "nsDefaultSOAPEncoder.h"
#include "nsHTTPSOAPTransport.h"
#include "nsSOAPPropertyBag.h"
#include "nsSchemaLoader.h"
#include "nsSchemaPrivate.h"
#include "nsWSDLLoader.h"
@ -89,6 +90,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoder_1_1)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoder_1_2)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSOAPTransport)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSSOAPTransport)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPPropertyBagMutator)
NS_DECL_CLASSINFO(nsSOAPCall)
NS_DECL_CLASSINFO(nsSOAPResponse)
NS_DECL_CLASSINFO(nsSOAPEncoding)
@ -98,6 +100,10 @@ NS_DECL_CLASSINFO(nsSOAPParameter)
NS_DECL_CLASSINFO(nsHTTPSOAPTransport)
NS_DECL_CLASSINFO(nsHTTPSOAPTransportCompletion)
NS_DECL_CLASSINFO(nsHTTPSSOAPTransport)
NS_DECL_CLASSINFO(nsSOAPPropertyBagMutator)
NS_DECL_CLASSINFO(nsSOAPProperty)
NS_DECL_CLASSINFO(nsSOAPPropertyBag)
NS_DECL_CLASSINFO(nsSOAPPropertyBagEnumerator)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSchemaLoader)
NS_DECL_CLASSINFO(nsSchemaLoader)
@ -266,6 +272,12 @@ RegisterXMLExtras(nsIComponentManager *aCompMgr,
PR_TRUE, PR_TRUE, getter_Copies(previous));
NS_ENSURE_SUCCESS(rv, rv);
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
"SOAPPropertyBagMutator",
NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID,
PR_TRUE, PR_TRUE, getter_Copies(previous));
NS_ENSURE_SUCCESS(rv, rv);
rv = catman->AddCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
"SchemaLoader",
NS_SCHEMALOADER_CONTRACTID,
@ -350,6 +362,30 @@ static nsModuleComponentInfo components[] = {
NS_CI_INTERFACE_GETTER_NAME(nsHTTPSSOAPTransport),
nsnull, &NS_CLASSINFO_NAME(nsHTTPSSOAPTransport),
nsIClassInfo::DOM_OBJECT },
{ "SOAP Property Bag Mutator", NS_SOAPPROPERTYBAGMUTATOR_CID,
NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID,
nsSOAPPropertyBagMutatorConstructor, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSOAPPropertyBagMutator),
nsnull, &NS_CLASSINFO_NAME(nsSOAPPropertyBagMutator),
nsIClassInfo::DOM_OBJECT },
{ "SOAP Property", NS_SOAPPROPERTY_CID,
NS_SOAPPROPERTY_CONTRACTID,
nsnull, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSOAPProperty),
nsnull, &NS_CLASSINFO_NAME(nsSOAPProperty),
nsIClassInfo::DOM_OBJECT },
{ "SOAP Property Bag", NS_SOAPPROPERTYBAG_CID,
NS_SOAPPROPERTYBAG_CONTRACTID,
nsnull, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSOAPPropertyBag),
nsnull, &NS_CLASSINFO_NAME(nsSOAPPropertyBag),
nsIClassInfo::DOM_OBJECT },
{ "SOAP Property Bag Enumerator", NS_SOAPPROPERTYBAGENUMERATOR_CID,
NS_SOAPPROPERTYBAGENUMERATOR_CONTRACTID,
nsnull, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSOAPPropertyBagEnumerator),
nsnull, &NS_CLASSINFO_NAME(nsSOAPPropertyBagEnumerator),
nsIClassInfo::DOM_OBJECT },
{ "SchemaLoader", NS_SCHEMALOADER_CID, NS_SCHEMALOADER_CONTRACTID,
nsSchemaLoaderConstructor, nsnull, nsnull, nsnull,
NS_CI_INTERFACE_GETTER_NAME(nsSchemaLoader), nsnull,

View File

@ -41,6 +41,7 @@ XPIDLSRCS = \
nsISOAPHeaderBlock.idl \
nsISOAPMessage.idl \
nsISOAPParameter.idl \
nsISOAPPropertyBagMutator.idl \
nsISOAPResponse.idl \
nsISOAPResponseListener.idl \
nsISOAPService.idl \

View File

@ -36,6 +36,7 @@ XPIDLSRCS = \
.\nsISOAPHeaderBlock.idl \
.\nsISOAPMessage.idl \
.\nsISOAPParameter.idl \
.\nsISOAPPropertyBagMutator.idl \
.\nsISOAPResponse.idl \
.\nsISOAPResponseListener.idl \
.\nsISOAPService.idl \

View File

@ -27,7 +27,7 @@
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
interface nsISOAPAttachments:nsISupports {
/**
* Get the attachment associated with a particular identifier.
@ -36,7 +36,7 @@ interface nsISOAPAttachments : nsISupports {
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
@ -45,6 +45,6 @@ void getAttachment(in AString aIdentifier);
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
AString attach();
};

View File

@ -49,7 +49,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(843afaa8-1dd2-11b2-8b0d-9b5d16fe64ea)]
interface nsISOAPBlock : nsISupports {
interface nsISOAPBlock:nsISupports {
/**
* Initialize the block for additional decoding information.
*
@ -57,8 +57,9 @@ interface nsISOAPBlock : nsISupports {
*
* @param aVersion SOAP version for decoding special header attributes.
*/
void init(in nsISOAPAttachments aAttachments, in unsigned short aVersion);
void init(in nsISOAPAttachments aAttachments,
in unsigned short aVersion);
/**
* The namespace URI of the block. Ignored if name is null.
* If this is modified, element is set to null and all

View File

@ -37,7 +37,7 @@ interface nsISOAPCallCompletion;
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
interface nsISOAPCall:nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
@ -59,9 +59,9 @@ interface nsISOAPCall : nsISOAPMessage {
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
@ -81,7 +81,7 @@ interface nsISOAPCall : nsISOAPMessage {
nsISOAPCallCompletion asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
%{C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \

View File

@ -33,25 +33,25 @@ interface nsISOAPResponseListener;
*/
[scriptable, uuid(86114dd8-1dd2-11b2-ab2b-91d0c995e03a)]
interface nsISOAPCallCompletion : nsISupports {
interface nsISOAPCallCompletion:nsISupports {
/**
* The call which was invoked (may have changed since
* the call was made).
*/
readonly attribute nsISOAPCall call;
readonly attribute nsISOAPCall call;
/**
* The response, if any, to the call.
*/
readonly attribute nsISOAPResponse response;
readonly attribute nsISOAPResponse response;
/**
* The listener to the call.
*/
readonly attribute nsISOAPResponseListener listener;
readonly attribute nsISOAPResponseListener listener;
/**
* Whether the call is complete.
*/
readonly attribute boolean isComplete;
readonly attribute boolean isComplete;
/**
* Cause the invoked method to abort, if it is not
@ -60,5 +60,5 @@ readonly attribute boolean isComplete;
* true as a result. False if it was already
* true or reamined false.
*/
boolean abort();
boolean abort();
};

View File

@ -35,7 +35,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
interface nsISOAPDecoder:nsISupports {
/**
* Decode the source DOM node
@ -53,9 +53,8 @@ interface nsISOAPDecoder : nsISupports {
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
nsIVariant decode(in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@ -33,7 +33,7 @@ interface nsISOAPAttachments;
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
interface nsISOAPEncoder:nsISupports {
/**
* Encode the source variant.
@ -58,12 +58,11 @@ interface nsISOAPEncoder : nsISupports {
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
nsIDOMElement encode(in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@ -47,7 +47,7 @@ interface nsISchemaCollection;
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
interface nsISOAPEncoding:nsISupports {
/**
* The name of the encoding as it is known to SOAP.
@ -71,9 +71,8 @@ interface nsISOAPEncoding : nsISupports {
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getAssociatedEncoding(
in AString aStyleURI,
in boolean aCreateIf);
nsISOAPEncoding getAssociatedEncoding(in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
@ -155,13 +154,12 @@ interface nsISOAPEncoding : nsISupports {
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
nsIDOMElement encode(in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
@ -179,13 +177,12 @@ interface nsISOAPEncoding : nsISupports {
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
nsIVariant decode(in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
%{C++
#define NS_SOAPENCODING_CID \
{ /* db612ec6-1dd1-11b2-a8bc-e6777bf70a30 */ \
0xdb612ec6, 0x1dd1, 0x11b2, \

View File

@ -31,7 +31,7 @@ interface nsIDOMElement;
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
interface nsISOAPFault:nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
@ -47,7 +47,7 @@ interface nsISOAPFault : nsISupports {
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
@ -59,7 +59,7 @@ interface nsISOAPFault : nsISupports {
readonly attribute nsIDOMElement detail;
};
%{ C++
%{C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \

View File

@ -35,7 +35,7 @@ interface nsISchemaType;
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISOAPBlock {
interface nsISOAPHeaderBlock:nsISOAPBlock {
/**
* The actor URI of the header block. If element is set,
* then this is a computed value. If this is modified,
@ -54,7 +54,7 @@ interface nsISOAPHeaderBlock : nsISOAPBlock {
attribute boolean mustUnderstand;
};
%{ C++
%{C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \

View File

@ -41,11 +41,11 @@ interface nsIVariant;
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
interface nsISOAPMessage:nsISupports {
const unsigned short VERSION_1_1 = 0;
const unsigned short VERSION_1_2 = 1;
const unsigned short VERSION_UNKNOWN = 32767;
const unsigned short VERSION_1_1 = 0;
const unsigned short VERSION_1_2 = 1;
const unsigned short VERSION_UNKNOWN = 32767;
/**
* The document which captures the message, if any. A simple
@ -113,7 +113,7 @@ interface nsISOAPMessage : nsISupports {
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
@ -152,13 +152,15 @@ interface nsISOAPMessage : nsISupports {
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in unsigned short aVersion,
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
void encode(in unsigned short aVersion,
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array,
size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock
aHeaderBlocks, in PRUint32 aParameterCount,[array,
size_is
(aParameterCount)]
in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
@ -170,7 +172,8 @@ interface nsISOAPMessage : nsISupports {
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
[array, size_is(aCount),
retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
@ -187,8 +190,9 @@ interface nsISOAPMessage : nsISupports {
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
out PRUint32 aCount,
[array, size_is(aCount),
retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established

View File

@ -34,10 +34,10 @@ interface nsISchemaType;
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISOAPBlock {
interface nsISOAPParameter:nsISOAPBlock {
};
%{ C++
%{C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \

View File

@ -0,0 +1,60 @@
/* -*- 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 nsIPropertyBag;
interface nsIVariant;
/**
* This permits construction by native or
* script code a property bag that is also
* usable by other xpconnect systems.
*/
[scriptable, uuid(f34cb3c8-1dd1-11b2-8a18-a93a99d92c08)]
interface nsISOAPPropertyBagMutator:nsISupports {
/**
* The property bag that is being constructed.
* After the mutator is destroyed, this is
* read-only. This will never be null.
*/
readonly attribute nsIPropertyBag propertyBag;
/**
* Add or replace a property to the
* newly-constructed property bag.
*
* @param aName The name of the property.
*
* @param aValue The value of the property.
*/
void addProperty(in AString aName, in nsIVariant aValue);
};
%{C++
#define NS_SOAPPROPERTYBAGMUTATOR_CID \
{ /* c63d2762-1dd1-11b2-b028-8f244edaa8a1 */ \
0xc63d2762, 0x1dd1, 0x11b2, \
{0xb0, 0x28, 0x8f, 0x24, 0x4e, 0xda, 0xa8, 0xa1} }
#define NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID \
"@mozilla.org/xmlextras/soap/propertybagmutator;1"
%}

View File

@ -34,7 +34,7 @@ interface nsISOAPFault;
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
interface nsISOAPResponse:nsISOAPMessage {
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
@ -43,7 +43,7 @@ interface nsISOAPResponse : nsISOAPMessage {
readonly attribute nsISOAPFault fault;
};
%{ C++
%{C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \

View File

@ -31,8 +31,9 @@ interface nsISOAPResponse;
* responses are expected.
*/
[scriptable, function, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
[scriptable, function,
uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener:nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
@ -55,7 +56,8 @@ interface nsISOAPResponseListener : nsISupports {
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in nsresult status, in boolean aLast);
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in nsresult status,
in boolean aLast);
};

View File

@ -33,7 +33,7 @@ interface nsISOAPResponseListener;
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
interface nsISOAPService:nsISupports {
/**
* Configuration object that may contain more info on the service
*/
@ -51,11 +51,11 @@ interface nsISOAPService : nsISupports {
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
%{C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \

View File

@ -77,7 +77,7 @@ interface nsISOAPServiceRegistry {
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
%{C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \

View File

@ -29,7 +29,7 @@ interface nsISOAPResponseListener;
interface nsISOAPCallCompletion;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
interface nsISOAPTransport:nsISupports {
/**
* Send the specified message to the specified destination.
@ -42,8 +42,7 @@ interface nsISOAPTransport : nsISupports {
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
void syncCall(in nsISOAPCall aCall, in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
@ -61,8 +60,8 @@ interface nsISOAPTransport : nsISupports {
* null if listener is null.
*/
nsISOAPCallCompletion asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
@ -79,7 +78,8 @@ interface nsISOAPTransport : nsISupports {
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
void addListener(in nsISOAPTransportListener aListener,
in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
@ -93,10 +93,11 @@ interface nsISOAPTransport : nsISupports {
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
void removeListener(in nsISOAPTransportListener aListener,
in boolean aCapture);
};
%{ C++
%{C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="

View File

@ -30,8 +30,9 @@ interface nsISOAPMessage;
* is recieved on a transport.
*/
[scriptable, function, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
[scriptable, function,
uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener:nsISupports {
/**
* This method is invoked when an unsolicited message is

View File

@ -40,6 +40,7 @@ CPPSRCS = \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPPropertyBag.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)

View File

@ -46,6 +46,7 @@ OBJS= \
.\$(OBJDIR)\nsSOAPHeaderBlock.obj \
.\$(OBJDIR)\nsSOAPMessage.obj \
.\$(OBJDIR)\nsSOAPParameter.obj \
.\$(OBJDIR)\nsSOAPPropertyBag.obj \
.\$(OBJDIR)\nsSOAPResponse.obj \
.\$(OBJDIR)\nsSOAPUtils.obj \
$(NULL)

File diff suppressed because it is too large Load Diff

View File

@ -25,14 +25,12 @@
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder_1_1 : public nsSOAPEncoding
{
class nsDefaultSOAPEncoder_1_1:public nsSOAPEncoding {
public:
nsDefaultSOAPEncoder_1_1();
};
class nsDefaultSOAPEncoder_1_2 : public nsSOAPEncoding
{
class nsDefaultSOAPEncoder_1_2:public nsSOAPEncoding {
public:
nsDefaultSOAPEncoder_1_2();
};

View File

@ -42,7 +42,6 @@ nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
#ifdef DEBUG
#define DEBUG_DUMP_DOCUMENT(message,doc) \
{ \
@ -55,95 +54,104 @@ NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
nsAutoString result(serial);\
printf(message ":\n%s\n", NS_ConvertUCS2toUTF8(result).get());\
}
// Availble from the debugger...
nsresult DebugPrintDOM(nsIDOMNode* node)
nsresult DebugPrintDOM(nsIDOMNode * node)
{
DEBUG_DUMP_DOCUMENT("DOM", node)
return NS_OK;
DEBUG_DUMP_DOCUMENT("DOM", node) return NS_OK;
}
#else
#define DEBUG_DUMP_DOCUMENT(message,doc)
#endif
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall * aCall,
nsISOAPResponse * aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr < nsIXMLHttpRequest > request;
nsCOMPtr<nsIDOMDocument> messageDocument;
nsCOMPtr < nsIDOMDocument > messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (!messageDocument)
return NS_ERROR_NOT_INITIALIZED;
DEBUG_DUMP_DOCUMENT("Synchronous Request", messageDocument)
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (AStringIsNull(uri))
return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
rv = request->SetRequestHeader("SOAPAction",
NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv))
return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
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;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument),
messageDocument);
if (NS_FAILED(rv))
return rv;
rv = request->Send(variant);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return 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 (NS_SUCCEEDED(rv) && (status < 200 || status >= 300))
rv = NS_ERROR_FAILURE;
if (NS_FAILED(rv))
return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
nsCOMPtr < nsIDOMDocument > response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (response) {
DEBUG_DUMP_DOCUMENT("Asynchronous Response", response)
}
DEBUG_DUMP_DOCUMENT("Asynchronous Response", response)}
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
return NS_OK;
}
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener, nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
NS_IMPL_ISUPPORTS2_CI(nsHTTPSOAPTransportCompletion, nsIDOMEventListener,
nsISOAPCallCompletion)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsISOAPCall *call,
nsISOAPResponse *response,
nsIXMLHttpRequest *request,
nsISOAPResponseListener *listener):
mCall(call), mResponse(response), mRequest(request), mListener(listener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(nsISOAPCall * call, nsISOAPResponse * response, nsIXMLHttpRequest * request, nsISOAPResponseListener * listener):
mCall(call), mResponse(response), mRequest(request), mListener(listener)
{
NS_INIT_ISUPPORTS();
}
@ -151,6 +159,7 @@ nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion(
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
/* readonly attribute nsISOAPCall call; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
{
@ -160,15 +169,20 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetCall(nsISOAPCall * *aCall)
}
/* readonly attribute nsISOAPResponse response; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse * *aResponse)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetResponse(nsISOAPResponse *
*aResponse)
{
*aResponse = mRequest ? (nsCOMPtr<nsISOAPResponse>)nsnull : mResponse;
*aResponse =
mRequest ? (nsCOMPtr < nsISOAPResponse >) nsnull : mResponse;
NS_IF_ADDREF(*aResponse);
return NS_OK;
}
/* readonly attribute nsISOAPResponseListener listener; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener * *aListener)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener *
*aListener)
{
*aListener = mListener;
NS_IF_ADDREF(*aListener);
@ -176,14 +190,15 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetListener(nsISOAPResponseListener
}
/* readonly attribute boolean isComplete; */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool *aIsComplete)
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::GetIsComplete(PRBool * aIsComplete)
{
*aIsComplete = mRequest == nsnull;
return NS_OK;
}
/* boolean abort (); */
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool * _retval)
{
if (mRequest) {
if (NS_SUCCEEDED(mRequest->Abort())) {
@ -195,96 +210,120 @@ NS_IMETHODIMP nsHTTPSOAPTransportCompletion::Abort(PRBool *_retval)
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent * aEvent)
{
PRUint32 status;
nsresult rv;
if (mRequest) { // Avoid if it has been aborted.
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 (NS_SUCCEEDED(rv) && (status < 200 || status >= 300))
rv = NS_ERROR_FAILURE;
if (mResponse && NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
nsCOMPtr < nsIDOMDocument > document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
rv = mResponse->SetMessage(document);
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)
rv = mResponse->SetMessage(document);
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)} else {
mResponse = nsnull;
}
else {
mResponse = nsnull;
}
}
else {
} else {
mResponse = nsnull;
}
nsCOMPtr<nsISOAPCallCompletion> kungFuDeathGrip = this;
mRequest = nsnull; // Break cycle of references by releas.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
nsCOMPtr < nsISOAPCallCompletion > kungFuDeathGrip = this;
mRequest = nsnull; // Break cycle of references by releas.
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, 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,
nsISOAPCallCompletion** aCompletion)
NS_IMETHODIMP
nsHTTPSOAPTransport::AsyncCall(nsISOAPCall * aCall,
nsISOAPResponseListener * aListener,
nsISOAPResponse * aResponse,
nsISOAPCallCompletion ** aCompletion)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr < nsIXMLHttpRequest > request;
nsCOMPtr<nsIDOMDocument> messageDocument;
nsCOMPtr < nsIDOMDocument > messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (!messageDocument)
return NS_ERROR_NOT_INITIALIZED;
DEBUG_DUMP_DOCUMENT("Asynchronous Request", messageDocument)
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMEventTarget > eventTarget =
do_QueryInterface(request, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
if (NS_FAILED(rv))
return rv;
if (AStringIsNull(uri))
return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
rv = request->SetRequestHeader("SOAPAction",
NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv))
return rv;
}
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
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;
rv = variant->SetAsInterface(NS_GET_IID(nsIDOMDocument),
messageDocument);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISOAPCallCompletion> completion;
nsCOMPtr < nsISOAPCallCompletion > completion;
if (aListener) {
completion = new nsHTTPSOAPTransportCompletion(aCall, aResponse, request, aListener);
if (!completion) return NS_ERROR_OUT_OF_MEMORY;
completion =
new nsHTTPSOAPTransportCompletion(aCall, aResponse, request,
aListener);
if (!completion)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(completion);
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 < nsIDOMEventListener > listener =
do_QueryInterface(completion);
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;
if (NS_FAILED(rv))
return rv;
*aCompletion = completion;
NS_IF_ADDREF(*aCompletion);
@ -293,15 +332,19 @@ NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponse
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
NS_IMETHODIMP
nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener * aListener,
PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
NS_IMETHODIMP
nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *
aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
nsHTTPSSOAPTransport::nsHTTPSSOAPTransport()

View File

@ -33,46 +33,41 @@
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
class nsHTTPSOAPTransport:public nsISOAPTransport {
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
virtual ~ nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT};
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
class nsHTTPSSOAPTransport: public nsHTTPSOAPTransport
{
class nsHTTPSSOAPTransport:public nsHTTPSOAPTransport {
public:
nsHTTPSSOAPTransport();
virtual ~nsHTTPSSOAPTransport();
virtual ~ nsHTTPSSOAPTransport();
NS_DECL_ISUPPORTS
};
NS_DECL_ISUPPORTS};
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener, public nsISOAPCallCompletion
{
class nsHTTPSOAPTransportCompletion:public nsIDOMEventListener,
public nsISOAPCallCompletion {
public:
nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall *call, nsISOAPResponse *response, nsIXMLHttpRequest *request, nsISOAPResponseListener *listener);
virtual ~nsHTTPSOAPTransportCompletion();
nsHTTPSOAPTransportCompletion(nsISOAPCall * call,
nsISOAPResponse * response,
nsIXMLHttpRequest * request,
nsISOAPResponseListener * listener);
virtual ~ nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPCALLCOMPLETION
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
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;
nsCOMPtr < nsISOAPCall > mCall;
nsCOMPtr < nsISOAPResponse > mResponse;
nsCOMPtr < nsIXMLHttpRequest > mRequest;
nsCOMPtr < nsISOAPResponseListener > mListener;
};
#define NS_HTTPSOAPTRANSPORT_CID \

View File

@ -37,13 +37,12 @@ nsSOAPBlock::~nsSOAPBlock()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPBlock,
nsISOAPBlock,
nsIJSNativeInitializer)
NS_IMETHODIMP nsSOAPBlock::Init(nsISOAPAttachments* aAttachments, PRUint16 aVersion) {
NS_IMPL_ISUPPORTS2(nsSOAPBlock, nsISOAPBlock, nsIJSNativeInitializer)
NS_IMETHODIMP nsSOAPBlock::Init(nsISOAPAttachments * aAttachments,
PRUint16 aVersion)
{
if (aVersion == nsISOAPMessage::VERSION_1_1
||aVersion == nsISOAPMessage::VERSION_1_2) {
|| aVersion == nsISOAPMessage::VERSION_1_2) {
mAttachments = aAttachments;
mVersion = aVersion;
return NS_OK;
@ -57,16 +56,17 @@ NS_IMETHODIMP nsSOAPBlock::GetNamespaceURI(nsAString & aNamespaceURI)
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
} else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetNamespaceURI(const nsAString & aNamespaceURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
@ -77,29 +77,31 @@ NS_IMETHODIMP nsSOAPBlock::GetName(nsAString & aName)
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
} else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetName(const nsAString & aName)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
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)
NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding * aEncoding)
{
mEncoding = aEncoding;
mComputeValue = PR_TRUE;
@ -107,14 +109,15 @@ NS_IMETHODIMP nsSOAPBlock::SetEncoding(nsISOAPEncoding* aEncoding)
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPBlock::GetSchemaType(nsISchemaType* * aSchemaType)
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)
NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType * aSchemaType)
{
mSchemaType = aSchemaType;
mComputeValue = PR_TRUE;
@ -122,14 +125,15 @@ NS_IMETHODIMP nsSOAPBlock::SetSchemaType(nsISchemaType* aSchemaType)
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPBlock::GetElement(nsIDOMElement* * aElement)
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)
NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement * aElement)
{
mElement = aElement;
mComputeValue = PR_TRUE;
@ -137,16 +141,17 @@ NS_IMETHODIMP nsSOAPBlock::SetElement(nsIDOMElement* aElement)
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant * *aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement) { // Check for auto-computation
if (mElement) { // Check for auto-computation
if (mComputeValue) {
mComputeValue = PR_FALSE;
if (mEncoding) {
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
else {
mStatus =
mEncoding->Decode(mElement, mSchemaType, mAttachments,
getter_AddRefs(mValue));
} else {
mStatus = NS_ERROR_NOT_INITIALIZED;
}
}
@ -156,51 +161,60 @@ NS_IMETHODIMP nsSOAPBlock::GetValue(nsIVariant* * aValue)
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant* aValue)
NS_IMETHODIMP nsSOAPBlock::SetValue(nsIVariant * aValue)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mValue = aValue;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
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;
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;
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;
if (NS_FAILED(rc))
return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
nsCOMPtr < nsISchemaType > v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc))
return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
nsCOMPtr < nsISOAPEncoding > v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc))
return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
}
return NS_OK;

View File

@ -33,30 +33,26 @@
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPBlock : public nsISOAPBlock,
public nsIJSNativeInitializer
{
class nsSOAPBlock:public nsISOAPBlock, public nsIJSNativeInitializer {
public:
nsSOAPBlock();
virtual ~nsSOAPBlock();
virtual ~ nsSOAPBlock();
NS_DECL_ISUPPORTS
// nsISOAPBlock
// nsISOAPBlock
NS_DECL_NSISOAPBLOCK
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
// 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;
nsCOMPtr < nsISOAPEncoding > mEncoding;
nsCOMPtr < nsISchemaType > mSchemaType;
nsCOMPtr < nsISOAPAttachments > mAttachments;
nsCOMPtr < nsIDOMElement > mElement;
nsCOMPtr < nsIVariant > mValue;
nsresult mStatus;
PRBool mComputeValue;
PRBool mVersion;

View File

@ -43,14 +43,12 @@ nsSOAPCall::~nsSOAPCall()
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAString & aTransportURI)
{
@ -58,32 +56,35 @@ NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAString & aTransportURI)
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
nsresult nsSOAPCall::GetTransport(nsISOAPTransport ** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsCOMPtr < nsIURI > uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsISOAPTransport > transport =
do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv))
return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
@ -92,55 +93,68 @@ nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse ** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
nsCOMPtr < nsISOAPTransport > transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISOAPResponse >
response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDOMDocument> document;
rv = response->GetMessage(getter_AddRefs(document)); // No XML response.
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMDocument > document;
rv = response->GetMessage(getter_AddRefs(document)); // No XML response.
if (NS_FAILED(rv))
return rv;
if (!document) {
*_retval = nsnull;
return NS_OK;
}
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
return response->QueryInterface(NS_GET_IID(nsISOAPResponse),
(void **) _retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener, nsISOAPCallCompletion ** aCompletion)
NS_IMETHODIMP
nsSOAPCall::AsyncInvoke(nsISOAPResponseListener * listener,
nsISOAPCallCompletion ** aCompletion)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
nsCOMPtr < nsISOAPTransport > transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISOAPResponse >
response(do_CreateInstance(NS_SOAPRESPONSE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = transport->AsyncCall(this, listener, response, aCompletion);
return rv;

View File

@ -30,25 +30,19 @@
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
class nsSOAPCall:public nsSOAPMessage, public nsISOAPCall {
public:
nsSOAPCall();
virtual ~nsSOAPCall();
virtual ~ nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL protected:
// nsISOAPCall
NS_DECL_NSISOAPCALL
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport ** aTransport);
};
#endif

View File

@ -36,9 +36,8 @@
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry, nsISOAPEncoding) nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding * aEncoding):mEncodings(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -55,21 +54,24 @@ nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(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);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
*aEncoding = (nsISOAPEncoding *) mEncodings->Get(&styleKey);
if (!*aEncoding) {
nsCOMPtr < nsISOAPEncoding > defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
nsCOMPtr < nsISOAPEncoding > encoding =
do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
*aEncoding = encoding;
NS_IF_ADDREF(*aEncoding);
mEncodings->Put(&styleKey, encoding);
@ -77,21 +79,30 @@ nsresult nsSOAPEncodingRegistry::GetAssociatedEncoding(const nsAString& aStyleUR
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
nsresult
nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection *
aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
nsresult
nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection **
aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsISchemaLoader > loader =
do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
if (!mSchemaCollection)
return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
@ -101,71 +112,99 @@ nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSche
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aKey, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aKey, nsISOAPEncoder *aEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetEncoder(const nsAString & aKey,
nsISOAPEncoder * aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aKey, nsISOAPEncoder **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetEncoder(const nsAString & aKey,
nsISOAPEncoder ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aKey, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aKey, nsISOAPDecoder *aDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDecoder(const nsAString & aKey,
nsISOAPDecoder * aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aKey, nsISOAPDecoder **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDecoder(const nsAString & aKey,
nsISOAPDecoder ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder *
*aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder *
aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder *
*aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder *
aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::Encode(nsIVariant * aSource,
const nsAString & aNamespaceURI,
const nsAString & aName,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIDOMElement * aDestination,
nsIDOMElement ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
NS_IMETHODIMP
nsSOAPEncodingRegistry::Decode(nsIDOMElement * aSource,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIVariant ** _retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS1_CI(nsSOAPEncoding, nsISOAPEncoding)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
NS_IMPL_ISUPPORTS1_CI(nsSOAPEncoding, nsISOAPEncoding) nsSOAPEncoding::nsSOAPEncoding():mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -176,20 +215,24 @@ nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(PRUint16 aVersion): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
nsSOAPEncoding::nsSOAPEncoding(PRUint16 aVersion):mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(*nsSOAPUtils::kSOAPEncURI[aVersion]);
mDefaultEncoding = do_GetService(aVersion ? NS_DEFAULTSOAPENCODER_1_2_CONTRACTID : NS_DEFAULTSOAPENCODER_1_1_CONTRACTID);
mDefaultEncoding =
do_GetService(aVersion ? NS_DEFAULTSOAPENCODER_1_2_CONTRACTID :
NS_DEFAULTSOAPENCODER_1_1_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
nsSOAPEncoding::nsSOAPEncoding(const nsAString & aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding * aDefaultEncoding):mEncoders(new nsSupportsHashtable),
mDecoders(new
nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
@ -207,12 +250,17 @@ nsSOAPEncoding::~nsSOAPEncoding()
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
nsresult
nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection *
aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
nsresult
nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection **
aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
@ -227,7 +275,10 @@ NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
}
/* nsISOAPEncoding getAssociatedEncoding (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI,
PRBool aCreateIf,
nsISOAPEncoding ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
@ -235,27 +286,30 @@ NS_IMETHODIMP nsSOAPEncoding::GetAssociatedEncoding(const nsAString & aStyleURI,
}
/* nsISOAPEncoder setEncoder (in AString aKey, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aKey, nsISOAPEncoder *aEncoder)
NS_IMETHODIMP
nsSOAPEncoding::SetEncoder(const nsAString & aKey,
nsISOAPEncoder * aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG(aEncoder);
nsStringKey nameKey(aKey);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
} else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aKey, nsISOAPEncoder **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetEncoder(const nsAString & aKey,
nsISOAPEncoder ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aKey);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
*_retval = (nsISOAPEncoder *) mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aKey, _retval);
}
@ -263,27 +317,30 @@ NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aKey, nsISOAPEncoder
}
/* nsISOAPDecoder setDecoder (in AString aKey, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aKey, nsISOAPDecoder *aDecoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDecoder(const nsAString & aKey,
nsISOAPDecoder * aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG(aDecoder);
nsStringKey nameKey(aKey);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
} else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aKey); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aKey, nsISOAPDecoder **_retval)
NS_IMETHODIMP
nsSOAPEncoding::GetDecoder(const nsAString & aKey,
nsISOAPDecoder ** _retval)
{
NS_SOAP_ENSURE_ARG_STRING(aKey);
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aKey);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
*_retval = (nsISOAPDecoder *) mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aKey, _retval);
}
@ -291,39 +348,55 @@ NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aKey, nsISOAPDecoder
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
NS_IMETHODIMP
nsSOAPEncoding::Encode(nsIVariant * aSource,
const nsAString & aNamespaceURI,
const nsAString & aName,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIDOMElement * aDestination,
nsIDOMElement ** _retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsCOMPtr < nsISOAPEncoder > encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
return encoder->Encode(this, aSource, aNamespaceURI, aName,
aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
NS_IMETHODIMP
nsSOAPEncoding::Decode(nsIDOMElement * aSource,
nsISchemaType * aSchemaType,
nsISOAPAttachments * aAttachments,
nsIVariant ** _retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsCOMPtr < nsISOAPDecoder > decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
return decoder->Decode(this, aSource, aSchemaType, aAttachments,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
@ -333,14 +406,17 @@ NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncode
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
@ -349,9 +425,11 @@ NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecode
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
NS_IMETHODIMP
nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;

View File

@ -35,39 +35,33 @@
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
class nsSOAPEncodingRegistry:public nsISOAPEncoding {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
NS_DECL_ISUPPORTS NS_DECL_NSISOAPENCODING nsSOAPEncodingRegistry() {
} nsSOAPEncodingRegistry(nsISOAPEncoding * aEncoding);
virtual ~ nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
nsSupportsHashtable * mEncodings;
nsCOMPtr < nsISchemaCollection > mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding
{
class nsSOAPEncoding:public nsISOAPEncoding {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncoding();
NS_DECL_ISUPPORTS NS_DECL_NSISOAPENCODING nsSOAPEncoding();
nsSOAPEncoding(PRUint16 aVersion);
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
nsSOAPEncoding(const nsAString & aStyleURI,
nsSOAPEncodingRegistry * aRegistry,
nsISOAPEncoding * aDefaultEncoding);
virtual ~ nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
nsSupportsHashtable *mEncoders;
nsSupportsHashtable *mDecoders;
nsCOMPtr < nsISOAPEncoding > mRegistry;
nsCOMPtr < nsISOAPEncoding > mDefaultEncoding;
nsCOMPtr < nsISOAPEncoder > mDefaultEncoder;
nsCOMPtr < nsISOAPDecoder > mDefaultDecoder;
};
#endif

View File

@ -35,35 +35,37 @@ nsSOAPFault::~nsSOAPFault()
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPFault, nsISOAPFault)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement * aElement)
{
if (aElement) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = aElement->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = aElement->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kFaultTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
mVersion = nsISOAPMessage::VERSION_1_2;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
mVersion = nsISOAPMessage::VERSION_1_1;
}
else {
if (namespaceURI.
Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
mVersion = nsISOAPMessage::VERSION_1_2;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
mVersion = nsISOAPMessage::VERSION_1_1;
} else {
return NS_ERROR_ILLEGAL_VALUE;
}
}
else {
} else {
return NS_ERROR_ILLEGAL_VALUE;
}
}
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
@ -76,13 +78,14 @@ NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
nsCOMPtr < nsIDOMElement > faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
@ -93,12 +96,15 @@ NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAString & aFaultCode)
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultStringTagName,
getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
@ -109,12 +115,15 @@ NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultActorTagName,
getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
@ -125,10 +134,13 @@ NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
if (!mFaultElement) return NS_ERROR_ILLEGAL_VALUE;
if (!mFaultElement)
return NS_ERROR_ILLEGAL_VALUE;
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, *nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultDetailTagName, aDetail);
nsCOMPtr < nsIDOMElement > element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kFaultDetailTagName,
aDetail);
return NS_OK;
}

View File

@ -28,19 +28,15 @@
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault
{
class nsSOAPFault:public nsISOAPFault {
public:
nsSOAPFault();
virtual ~nsSOAPFault();
virtual ~ nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
// nsISOAPFault
NS_DECL_NSISOAPFAULT protected:
nsCOMPtr < nsIDOMElement > mFaultElement;
PRUint16 mVersion;
};
#endif

View File

@ -33,16 +33,15 @@ nsSOAPHeaderBlock::nsSOAPHeaderBlock()
NS_INIT_ISUPPORTS();
}
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_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()
{
}
@ -51,46 +50,64 @@ NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN) return NS_ERROR_NOT_AVAILABLE;
return mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN)
return NS_ERROR_NOT_AVAILABLE;
return mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kActorAttribute,
aActorURI);
} else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAString & aActorURI)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute AString mustUnderstand; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool * aMustUnderstand)
NS_IMETHODIMP nsSOAPHeaderBlock::GetMustUnderstand(PRBool *
aMustUnderstand)
{
NS_ENSURE_ARG_POINTER(&aMustUnderstand);
if (mElement) {
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN) return NS_ERROR_NOT_AVAILABLE;
if (mVersion == nsISOAPMessage::VERSION_UNKNOWN)
return NS_ERROR_NOT_AVAILABLE;
nsAutoString m;
nsresult rc = mElement->GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],nsSOAPUtils::kMustUnderstandAttribute,m);
if (NS_FAILED(rc)) return rc;
if (m.Length() == 0) *aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrue) || m.Equals(nsSOAPUtils::kTrueA)) *aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalse) || m.Equals(nsSOAPUtils::kFalseA)) *aMustUnderstand = PR_FALSE;
else return NS_ERROR_ILLEGAL_VALUE;
nsresult
rc =
mElement->
GetAttributeNS(*nsSOAPUtils::kSOAPEnvURI[mVersion],
nsSOAPUtils::kMustUnderstandAttribute, m);
if (NS_FAILED(rc))
return rc;
if (m.Length() == 0)
*aMustUnderstand = PR_FALSE;
else if (m.Equals(nsSOAPUtils::kTrue)
|| m.Equals(nsSOAPUtils::kTrueA))
*aMustUnderstand = PR_TRUE;
else if (m.Equals(nsSOAPUtils::kFalse)
|| m.Equals(nsSOAPUtils::kFalseA))
*aMustUnderstand = PR_FALSE;
else
return NS_ERROR_ILLEGAL_VALUE;
return NS_OK;
}
else {
} else {
*aMustUnderstand = mMustUnderstand;
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetMustUnderstand(PRBool aMustUnderstand)
{
nsresult rc = SetElement(nsnull);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
mMustUnderstand = aMustUnderstand;
return NS_OK;
}

View File

@ -34,22 +34,15 @@
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPHeaderBlock : public nsSOAPBlock,
public nsISOAPHeaderBlock
{
class nsSOAPHeaderBlock:public nsSOAPBlock, public nsISOAPHeaderBlock {
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
virtual ~ nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
protected:
nsString mActorURI;
NS_DECL_ISUPPORTS NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK protected:
nsString mActorURI;
PRBool mMustUnderstand;
};

View File

@ -39,7 +39,7 @@ static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
@ -49,9 +49,7 @@ nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS1(nsSOAPMessage,
nsISOAPMessage)
NS_IMPL_ISUPPORTS1(nsSOAPMessage, nsISOAPMessage)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
@ -60,6 +58,7 @@ NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
@ -72,53 +71,63 @@ NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = root->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = root->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
|| namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
&& (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])
|| namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1]))) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute PRUint16 version; */
NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 *aVersion)
NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 * aVersion)
{
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
nsAutoString name;
nsresult rc = root->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
rc = root->GetLocalName(name);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aVersion = nsISOAPMessage::VERSION_1_2;
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aVersion = nsISOAPMessage::VERSION_1_2;
return NS_OK;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aVersion = nsISOAPMessage::VERSION_1_1;
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aVersion = nsISOAPMessage::VERSION_1_1;
return NS_OK;
}
}
}
}
}
*aVersion = nsISOAPMessage::VERSION_UNKNOWN;
return NS_OK;
@ -128,7 +137,7 @@ NS_IMETHODIMP nsSOAPMessage::GetVersion(PRUint16 *aVersion)
PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
{
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
nsCOMPtr < nsIDOMElement > root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString namespaceURI;
@ -136,18 +145,21 @@ PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
root->GetNamespaceURI(namespaceURI);
root->GetLocalName(name);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)) {
if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_2])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_2;
}
else if (namespaceURI.Equals(*nsSOAPUtils::kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
} else if (namespaceURI.
Equals(*nsSOAPUtils::
kSOAPEnvURI[nsISOAPMessage::VERSION_1_1])) {
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return nsISOAPMessage::VERSION_1_1;
}
}
}
}
}
*aEnvelope = nsnull;
return nsISOAPMessage::VERSION_UNKNOWN;
@ -157,14 +169,15 @@ PRUint16 nsSOAPMessage::GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope)
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
nsCOMPtr < nsIDOMElement > env;
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kHeaderTagName,
aHeader);
} else {
*aHeader = nsnull;
}
return NS_OK;
@ -174,14 +187,14 @@ NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
nsCOMPtr < nsIDOMElement > env;
PRUint16 version = GetEnvelopeWithVersion(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kBodyTagName,
aBody);
}
else {
nsSOAPUtils::GetSpecificChildElement(env,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kBodyTagName, aBody);
} else {
*aBody = nsnull;
}
return NS_OK;
@ -194,6 +207,7 @@ NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAString & aActionURI)
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAString & aActionURI)
{
mActionURI.Assign(aActionURI);
@ -204,10 +218,10 @@ NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAString & aActionURI)
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsCOMPtr < nsIDOMElement > method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
@ -219,13 +233,14 @@ NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
NS_IMETHODIMP nsSOAPMessage::
GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsCOMPtr < nsIDOMElement > method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
@ -236,183 +251,236 @@ NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
return NS_OK;
}
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1, "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/1999/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2, "<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr1,
"<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/1999/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
NS_NAMED_LITERAL_STRING(realEmptySOAPDocStr2,
"<env:Envelope xmlns:env=\"http://www.w3.org/2001/09/soap-envelope\" xmlns:enc=\"http://www.w3.org/2001/09/soap-encoding\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"><env:Header/><env:Body/></env:Envelope>");
const nsAString* kEmptySOAPDocStr[] = {&realEmptySOAPDocStr1, &realEmptySOAPDocStr2};
const nsAString *kEmptySOAPDocStr[] =
{ &realEmptySOAPDocStr1, &realEmptySOAPDocStr2
};
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(PRUint16 aVersion, const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
NS_IMETHODIMP
nsSOAPMessage::Encode(PRUint16 aVersion, const nsAString & aMethodName,
const nsAString & aTargetObjectURI,
PRUint32 aHeaderBlockCount,
nsISOAPHeaderBlock ** aHeaderBlocks,
PRUint32 aParameterCount,
nsISOAPParameter ** aParameters)
{
if (aVersion != nsISOAPMessage::VERSION_1_1
&& aVersion != nsISOAPMessage::VERSION_1_2)
return NS_ERROR_ILLEGAL_VALUE;
&& aVersion != nsISOAPMessage::VERSION_1_2)
return NS_ERROR_ILLEGAL_VALUE;
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMNode > ignored;
nsCOMPtr < nsIDOMParser > parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv))
return rv;
nsAutoString docstr;
rv = parser->ParseFromString(nsString(*kEmptySOAPDocStr[aVersion]).get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
rv = parser->ParseFromString(nsString(*kEmptySOAPDocStr[aVersion]).get(),
"text/xml", getter_AddRefs(mMessage));
if (NS_FAILED(rv))
return rv;
// Declare the default encoding. This should always be non-null, but may be empty string.
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (encoding) {
nsCOMPtr<nsIDOMElement> envelope;
nsCOMPtr < nsIDOMElement > envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (envelope) {
nsAutoString enc;
rv = mEncoding->GetStyleURI(enc);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!enc.IsEmpty()) {
rv = envelope->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
if (NS_FAILED(rv)) return rv;
rv = envelope->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::
kEncodingStyleAttribute, enc);
if (NS_FAILED(rv))
return rv;
}
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
nsCOMPtr < nsIDOMElement > parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsISupports > next;
nsCOMPtr < nsISOAPHeaderBlock > header;
nsCOMPtr < nsIDOMElement > element;
nsCOMPtr < nsISchemaType > schemaType;
nsCOMPtr < nsIVariant > value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
PRBool mustUnderstand;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
if (!header)
return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMNode > node1 = (nsIDOMElement *) element;
nsCOMPtr < nsIDOMNode > node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv))
return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv))
return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetMustUnderstand(&mustUnderstand);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
} else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv))
return rv;
rv = header->GetName(name);
if (NS_FAILED(rv))
return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv))
return rv;
rv = header->GetMustUnderstand(&mustUnderstand);
if (NS_FAILED(rv))
return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv))
return rv;
if (!encoding) {
rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
if (NS_FAILED(rv)) return rv;
}
if (mustUnderstand) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kMustUnderstandAttribute, nsSOAPUtils::kTrueA);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv))
return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv))
return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent,
getter_AddRefs(element));
if (NS_FAILED(rv))
return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::kActorAttribute, actorURI);
if (NS_FAILED(rv))
return rv;
}
if (mustUnderstand) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix,
nsSOAPUtils::
kMustUnderstandAttribute,
nsSOAPUtils::kTrueA);
if (NS_FAILED(rv))
return rv;
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->
SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr < nsIDOMElement > call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName,
getter_AddRefs(call));
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMNode > ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefix(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> newencoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsCOMPtr < nsISupports > next;
nsCOMPtr < nsISOAPParameter > param;
nsCOMPtr < nsIDOMElement > element;
nsCOMPtr < nsISOAPEncoding > newencoding;
nsCOMPtr < nsISchemaType > schemaType;
nsCOMPtr < nsIVariant > value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
if (!param)
return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
nsCOMPtr < nsIDOMNode > node1 = (nsIDOMElement *) element;
nsCOMPtr < nsIDOMNode > node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
element = do_QueryInterface(node1);
}
else {
} else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetEncoding(getter_AddRefs(newencoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (!newencoding) {
newencoding = encoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = newencoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
schemaType, nsnull, body,
getter_AddRefs(element));
if (NS_FAILED(rv))
return rv;
if (encoding != newencoding) {
nsAutoString enc;
newencoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion], nsSOAPUtils::kEncodingStyleAttribute, enc);
nsAutoString enc;
newencoding->GetStyleURI(enc);
element->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[aVersion],
nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
@ -427,44 +495,53 @@ static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
* found a starting point, so it is used but not checked again. We
* also know that since there is a version, there is an encoding.
*/
nsresult nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement* aFirst, PRUint16 *aVersion, nsISOAPEncoding **aEncoding)
nsresult
nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement * aFirst,
PRUint16 * aVersion,
nsISOAPEncoding ** aEncoding)
{
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
nsresult rv = GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = GetVersion(aVersion);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> element = aFirst;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMElement > element = aFirst;
// Check for stray encodingStyle attributes. If none found, then use empty string encoding style.
nsAutoString style;
for (;;) {
nsCOMPtr<nsIDOMAttr> enc;
rv = element->GetAttributeNodeNS(*nsSOAPUtils::kSOAPEncURI[*aVersion], nsSOAPUtils::kEncodingStyleAttribute, getter_AddRefs(enc));
if (NS_FAILED(rv)) return rv;
nsCOMPtr < nsIDOMAttr > enc;
rv = element->GetAttributeNodeNS(*nsSOAPUtils::kSOAPEncURI[*aVersion],
nsSOAPUtils::kEncodingStyleAttribute,
getter_AddRefs(enc));
if (NS_FAILED(rv))
return rv;
if (enc) {
rv = enc->GetNodeValue(style);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
break;
}
else {
nsCOMPtr<nsIDOMNode>next;
} else {
nsCOMPtr < nsIDOMNode > next;
rv = element->GetParentNode(getter_AddRefs(next));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
if (next) {
PRUint16 type;
rv = element->GetNodeType(&type);
if (NS_FAILED(rv)) return rv;
PRUint16 type;
rv = element->GetNodeType(&type);
if (NS_FAILED(rv))
return rv;
if (type != nsIDOMNode::ELEMENT_NODE) {
next = nsnull;
next = nsnull;
}
}
if (next) {
element = do_QueryInterface(next);
}
else {
break;
} else {
break;
}
}
}
@ -472,33 +549,41 @@ nsresult nsSOAPMessage::GetEncodingWithVersion(nsIDOMElement* aFirst, PRUint16 *
}
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
NS_IMETHODIMP
nsSOAPMessage::GetHeaderBlocks(PRUint32 * aCount,
nsISOAPHeaderBlock *** aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
nsCOMPtr < nsIMemory > memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr < nsIDOMElement > element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv) || !element) return rv;
nsCOMPtr<nsISOAPEncoding> encoding;
if (NS_FAILED(rv) || !element)
return rv;
nsCOMPtr < nsISOAPEncoding > encoding;
PRUint16 version;
rv = GetEncodingWithVersion(element, &version, getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
if (NS_FAILED(rv))
return rv;
nsCOMPtr < nsIDOMElement > next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr < nsISOAPHeaderBlock > header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
*aHeaderBlocks =
(nsISOAPHeaderBlock * *)memory->Realloc(*aHeaderBlocks,
length *
sizeof(**aHeaderBlocks));
}
element = next;
header = do_CreateInstance(NS_SOAPHEADERBLOCK_CONTRACTID);
if (!header) return NS_ERROR_OUT_OF_MEMORY;
if (!header)
return NS_ERROR_OUT_OF_MEMORY;
header->Init(nsnull, version);
(*aHeaderBlocks)[(*aCount)] = header;
@ -506,86 +591,111 @@ NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBloc
(*aCount)++;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = header->SetEncoding(encoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
*aHeaderBlocks =
(nsISOAPHeaderBlock * *)memory->Realloc(*aHeaderBlocks,
(*aCount) *
sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
NS_IMETHODIMP
nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 * aCount,
nsISOAPParameter *** aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
nsCOMPtr < nsIMemory > memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr < nsIDOMElement > element;
nsresult rv = GetBody(getter_AddRefs(element));
if (NS_FAILED(rv) || !element) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
if (NS_FAILED(rv) || !element)
return rv;
nsCOMPtr < nsIDOMElement > next;
nsCOMPtr < nsISOAPParameter > param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
if (!aDocumentStyle) {
element = next;
if (!element) return NS_ERROR_ILLEGAL_VALUE;
if (!element)
return NS_ERROR_ILLEGAL_VALUE;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
}
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr < nsISOAPEncoding > encoding;
PRUint16 version;
rv = GetEncodingWithVersion(element, &version, getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
*aParameters =
(nsISOAPParameter * *)memory->Realloc(*aParameters,
length *
sizeof(**aParameters));
}
element = next;
param = do_CreateInstance(NS_SOAPPARAMETER_CONTRACTID);
if (!param) return NS_ERROR_OUT_OF_MEMORY;
if (!param)
return NS_ERROR_OUT_OF_MEMORY;
(*aParameters)[(*aCount)] = param;
NS_ADDREF((*aParameters)[(*aCount)]);
(*aCount)++;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
rv = param->SetEncoding(encoding);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv))
return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
*aParameters =
(nsISOAPParameter * *)memory->Realloc(*aParameters,
(*aCount) *
sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding * *aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
PRUint16 version;
nsresult rc = GetVersion(&version);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (version != nsISOAPMessage::VERSION_UNKNOWN) {
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
nsCOMPtr < nsISOAPEncoding > encoding =
do_CreateInstance(NS_SOAPENCODING_CONTRACTID);
if (!encoding)
return NS_ERROR_OUT_OF_MEMORY;
rc = encoding->GetAssociatedEncoding(*nsSOAPUtils::kSOAPEncURI[version], PR_FALSE, getter_AddRefs(mEncoding));
if (NS_FAILED(rc)) return rc;
return NS_ERROR_OUT_OF_MEMORY;
rc = encoding->
GetAssociatedEncoding(*nsSOAPUtils::kSOAPEncURI[version],
PR_FALSE, getter_AddRefs(mEncoding));
if (NS_FAILED(rc))
return rc;
}
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding * aEncoding)
{
mEncoding = aEncoding;
return NS_OK;

View File

@ -32,23 +32,21 @@
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage
{
class nsSOAPMessage:public nsISOAPMessage {
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
virtual ~ nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
protected:
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE protected:
PRUint16 GetEnvelopeWithVersion(nsIDOMElement * *aEnvelope);
nsresult GetEncodingWithVersion(nsIDOMElement *aFirst, PRUint16 *aVersion, nsISOAPEncoding **aEncoding);
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsresult GetEncodingWithVersion(nsIDOMElement * aFirst,
PRUint16 * aVersion,
nsISOAPEncoding ** aEncoding);
nsCOMPtr < nsIDOMDocument > mMessage;
nsCOMPtr < nsISOAPEncoding > mEncoding;
nsString mActionURI;
};

View File

@ -32,15 +32,14 @@ nsSOAPParameter::nsSOAPParameter()
NS_INIT_ISUPPORTS();
}
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_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()
nsSOAPParameter::~nsSOAPParameter()
{
}

View File

@ -34,19 +34,13 @@
#include "nsCOMPtr.h"
#include "nsSOAPBlock.h"
class nsSOAPParameter : public nsSOAPBlock,
public nsISOAPParameter
{
class nsSOAPParameter:public nsSOAPBlock, public nsISOAPParameter {
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
virtual ~ nsSOAPParameter();
NS_DECL_ISUPPORTS
NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
};
NS_DECL_ISUPPORTS NS_FORWARD_NSISOAPBLOCK(nsSOAPBlock::)
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER};
#endif

View File

@ -0,0 +1,271 @@
/* -*- 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) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsSOAPPropertyBag.h"
#include "nsIXPConnect.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsSupportsArray.h"
#include "nsHashtable.h"
#include "jsapi.h"
#include "nsIXPCScriptable.h"
class nsSOAPPropertyBagEnumerator;
class nsSOAPPropertyBag:public nsIPropertyBag, public nsIXPCScriptable {
public:
nsSOAPPropertyBag();
virtual ~ nsSOAPPropertyBag();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROPERTYBAG
NS_DECL_NSIXPCSCRIPTABLE
nsresult SetProperty(const nsAString & aName, nsIVariant * aValue);
protected:
nsSupportsHashtable * mProperties;
friend nsSOAPPropertyBagEnumerator;
};
class nsSOAPProperty:public nsIProperty {
public:
nsSOAPProperty(const nsAString & aName, nsIVariant * aValue);
virtual ~ nsSOAPProperty();
NS_DECL_ISUPPORTS
NS_DECL_NSIPROPERTY
protected:
nsString mName;
nsCOMPtr < nsIVariant > mValue;
};
class nsSOAPPropertyBagEnumerator:public nsISimpleEnumerator {
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsSOAPPropertyBagEnumerator methods:
nsSOAPPropertyBagEnumerator(nsSOAPPropertyBag * aPropertyBag);
virtual ~nsSOAPPropertyBagEnumerator();
protected:
nsCOMPtr < nsSupportsArray > mProperties;
PRUint32 mCurrent;
};
NS_IMPL_ISUPPORTS2_CI(nsSOAPPropertyBag, nsIPropertyBag, nsIXPCScriptable)
nsSOAPPropertyBag::nsSOAPPropertyBag():mProperties(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* property initializers and constructor code */
}
nsSOAPPropertyBag::~nsSOAPPropertyBag()
{
/* destructor code */
delete mProperties;
}
/* nsIVariant getProperty (in AString name); */
NS_IMETHODIMP
nsSOAPPropertyBag::GetProperty(const nsAString & aName,
nsIVariant ** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsStringKey nameKey(aName);
*_retval = NS_STATIC_CAST(nsIVariant *, mProperties->Get(&nameKey));
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBag::SetProperty(const nsAString & aName,
nsIVariant * aValue)
{
NS_ENSURE_ARG_POINTER(&aName);
NS_ENSURE_ARG_POINTER(aValue);
nsStringKey nameKey(aName);
return mProperties->Put(&nameKey, aValue);
}
// The nsIXPCScriptable map declaration that will generate stubs for us...
#define XPC_MAP_CLASSNAME nsSOAPPropertyBag
#define XPC_MAP_QUOTED_CLASSNAME "SOAPPropertyBag"
#define XPC_MAP_WANT_SETPROPERTY
#define XPC_MAP_WANT_GETPROPERTY
#define XPC_MAP_FLAGS nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
#include "xpc_map_end.h" /* This will #undef the above */
NS_IMETHODIMP
nsSOAPPropertyBag::GetProperty(nsIXPConnectWrappedNative * wrapper,
JSContext * cx, JSObject * obj,
jsval id, jsval * vp, PRBool * _retval)
{
if (JSVAL_IS_STRING(id)) {
JSString *str = JSVAL_TO_STRING(id);
const PRUnichar *name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr < nsIVariant > value =
dont_AddRef(NS_STATIC_CAST
(nsIVariant *, mProperties->Get(&nameKey)));
if (value == nsnull)
return NS_OK;
void *mark;
jsval *argv = JS_PushArguments(cx, &mark, "/%iv", value.get());
*vp = *argv;
JS_PopArguments(cx, mark);
}
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBag::SetProperty(nsIXPConnectWrappedNative * wrapper,
JSContext * cx, JSObject * obj,
jsval id, jsval * vp, PRBool * _retval)
{
if (JSVAL_IS_STRING(id)) {
JSString *str = JSVAL_TO_STRING(id);
const PRUnichar *name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr < nsIVariant > value; // Call to convert to variant.
if (!JS_ConvertArguments(cx, 1, vp, "/%iv", getter_AddRefs(value)))
return NS_ERROR_ILLEGAL_VALUE;
mProperties->Put(&nameKey, value);
}
return NS_OK;
}
PRBool PropertyBagEnumFunc(nsHashKey * aKey, void *aData, void *aClosure)
{
nsISupportsArray *properties =
NS_STATIC_CAST(nsISupportsArray *, aClosure);
nsAutoString name(NS_STATIC_CAST(nsStringKey *, aKey)->GetString());
properties->
AppendElement(new
nsSOAPProperty(name,
NS_STATIC_CAST(nsIVariant *, aData)));
return PR_TRUE;
}
nsSOAPPropertyBagEnumerator::nsSOAPPropertyBagEnumerator(nsSOAPPropertyBag * aPropertyBag):mProperties(new nsSupportsArray()),
mCurrent
(0)
{
NS_INIT_REFCNT();
aPropertyBag->mProperties->Enumerate(&PropertyBagEnumFunc, mProperties);
}
nsSOAPPropertyBagEnumerator::~nsSOAPPropertyBagEnumerator()
{
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPPropertyBagEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP nsSOAPPropertyBagEnumerator::GetNext(nsISupports ** aItem)
{
NS_ENSURE_ARG_POINTER(aItem);
PRUint32 count;
mProperties->Count(&count);
if (mCurrent < count) {
*aItem = mProperties->ElementAt(mCurrent++);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSOAPPropertyBagEnumerator::HasMoreElements(PRBool * aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
PRUint32 count;
mProperties->Count(&count);
*aResult = mCurrent < count;
return NS_OK;
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPProperty, nsIProperty)
nsSOAPProperty::nsSOAPProperty(const nsAString & aName,
nsIVariant * aValue):mName(aName), mValue(aValue) {
NS_INIT_REFCNT();
}
nsSOAPProperty::~nsSOAPProperty()
{
}
NS_IMETHODIMP nsSOAPProperty::GetName(nsAString & _retval) {
NS_ENSURE_ARG_POINTER(&_retval);
_retval.Assign(mName);
return NS_OK;
}
NS_IMETHODIMP nsSOAPProperty::GetValue(nsIVariant** _retval) {
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mValue;
NS_ADDREF(*_retval);
return NS_OK;
}
/* readonly attribute nsISimpleEnumerator enumerator; */
NS_IMETHODIMP
nsSOAPPropertyBag::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
{
NS_ENSURE_ARG_POINTER(aEnumerator);
*aEnumerator = new nsSOAPPropertyBagEnumerator(this);
if (aEnumerator) {
NS_ADDREF(*aEnumerator);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
}
nsSOAPPropertyBagMutator::nsSOAPPropertyBagMutator()
{
NS_INIT_REFCNT();
mBag = mSOAPBag = new nsSOAPPropertyBag();
}
nsSOAPPropertyBagMutator::~nsSOAPPropertyBagMutator()
{
}
NS_IMPL_ISUPPORTS1_CI(nsSOAPPropertyBagMutator, nsISOAPPropertyBagMutator)
NS_IMETHODIMP nsSOAPPropertyBagMutator::GetPropertyBag(nsIPropertyBag ** aPropertyBag) {
NS_ENSURE_ARG_POINTER(aPropertyBag);
*aPropertyBag = mBag;
NS_ADDREF(*aPropertyBag);
return NS_OK;
}
NS_IMETHODIMP
nsSOAPPropertyBagMutator::AddProperty(const nsAString & aName,
nsIVariant * aValue)
{
NS_ENSURE_ARG_POINTER(&aName);
NS_ENSURE_ARG_POINTER(aValue);
return mSOAPBag->SetProperty(aName, aValue);
}

View File

@ -0,0 +1,64 @@
/* -*- 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) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPPropertyBag_h__
#define nsSOAPPropertyBag_h__
#include "nsString.h"
#include "nsIPropertyBag.h"
#include "nsISOAPPropertyBagMutator.h"
#include "nsCOMPtr.h"
#include "nsIXPCScriptable.h"
#include "nsHashtable.h"
#include "nsSupportsArray.h"
class nsSOAPPropertyBag;
class nsSOAPPropertyBagMutator:public nsISOAPPropertyBagMutator {
public:
nsSOAPPropertyBagMutator();
virtual ~nsSOAPPropertyBagMutator();
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPPROPERTYBAGMUTATOR
protected:
nsCOMPtr<nsIPropertyBag> mBag;
nsSOAPPropertyBag* mSOAPBag;
};
#define NS_SOAPPROPERTY_CID \
{ /* 147d8bfe-1dd2-11b2-b72e-bba9d7a0dab7 */ \
0x147d8bfe, 0x1dd2, 0x11b2, \
{0xb7, 0x2e, 0xbb, 0xa9, 0xd7, 0xa0, 0xda, 0xb7} }
#define NS_SOAPPROPERTY_CONTRACTID "@mozilla.org/xmlextras/soap/property;1"
#define NS_SOAPPROPERTYBAG_CID \
{ /* 205621ac-1dd2-11b2-8c86-ede3fe564ef1 */ \
0x205621ac, 0x1dd2, 0x11b2, \
{0x8c, 0x86, 0xed, 0xe3, 0xfe, 0x56, 0x4e, 0xf1} }
#define NS_SOAPPROPERTYBAG_CONTRACTID "@mozilla.org/xmlextras/soap/property/bag;1"
#define NS_SOAPPROPERTYBAGENUMERATOR_CID \
{ /* 34e1f484-1dd2-11b2-a8c0-f20a9f3a0c55 */ \
0x34e1f484, 0x1dd2, 0x11b2, \
{0xa8, 0xc0, 0xf2, 0x0a, 0x9f, 0x3a, 0x0c, 0x55} }
#define NS_SOAPPROPERTYBAGENUMERATOR_CONTRACTID "@mozilla.org/xmlextras/soap/property/bag/enumerator;1"
#endif

View File

@ -38,46 +38,49 @@ nsSOAPResponse::~nsSOAPResponse()
/* destructor code */
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPResponse, nsISOAPMessage, nsISOAPResponse)
NS_IMPL_ADDREF_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPResponse)
NS_INTERFACE_MAP_ENTRY(nsISOAPResponse)
NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPResponse, nsISOAPMessage,
nsISOAPResponse)
NS_IMPL_ADDREF_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPResponse, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPResponse)
NS_INTERFACE_MAP_ENTRY(nsISOAPResponse)
NS_IMPL_QUERY_CLASSINFO(nsSOAPResponse)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
nsCOMPtr < nsIDOMElement > body;
*aFault = nsnull;
nsresult rc = GetBody(getter_AddRefs(body));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (body) {
PRUint16 version;
rc = GetVersion(&version);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (rc != nsSOAPMessage::VERSION_UNKNOWN) {
nsCOMPtr<nsIDOMElement> fault;
nsSOAPUtils::GetSpecificChildElement(body,
*nsSOAPUtils::kSOAPEnvURI[version], nsSOAPUtils::kFaultTagName,
getter_AddRefs(fault));
nsCOMPtr < nsIDOMElement > fault;
nsSOAPUtils::GetSpecificChildElement(body,
*nsSOAPUtils::
kSOAPEnvURI[version],
nsSOAPUtils::kFaultTagName,
getter_AddRefs(fault));
if (fault) {
nsCOMPtr<nsISOAPFault> f = do_CreateInstance(NS_SOAPFAULT_CONTRACTID);
if (!f)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr < nsISOAPFault > f =
do_CreateInstance(NS_SOAPFAULT_CONTRACTID);
if (!f)
return NS_ERROR_OUT_OF_MEMORY;
rc = f->SetElement(fault);
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
*aFault = f;
NS_ADDREF(*aFault);
NS_ADDREF(*aFault);
}
}
}
else {
} else {
*aFault = nsnull;
}
return NS_OK;

View File

@ -30,20 +30,14 @@
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
class nsSOAPResponse:public nsSOAPMessage, public nsISOAPResponse {
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
nsSOAPResponse();
virtual ~nsSOAPResponse();
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE nsSOAPResponse();
virtual ~ nsSOAPResponse();
protected:
};

View File

@ -26,126 +26,144 @@
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(realSOAPEnvURI1,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(realSOAPEnvURI2,"http://www.w3.org/2001/09/soap-envelope");
const nsAString* nsSOAPUtils::kSOAPEnvURI[] = {&realSOAPEnvURI1, &realSOAPEnvURI2};
NS_NAMED_LITERAL_STRING(realSOAPEnvURI1,
"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(realSOAPEnvURI2,
"http://www.w3.org/2001/09/soap-envelope");
const nsAString *nsSOAPUtils::kSOAPEnvURI[] =
{ &realSOAPEnvURI1, &realSOAPEnvURI2
};
NS_NAMED_LITERAL_STRING(realSOAPEncURI1,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(realSOAPEncURI2,"http://www.w3.org/2001/09/soap-encoding");
const nsAString* nsSOAPUtils::kSOAPEncURI[] = {&realSOAPEncURI1, &realSOAPEncURI2};
NS_NAMED_LITERAL_STRING(realSOAPEncURI1,
"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(realSOAPEncURI2,
"http://www.w3.org/2001/09/soap-encoding");
const nsAString *nsSOAPUtils::kSOAPEncURI[] =
{ &realSOAPEncURI1, &realSOAPEncURI2
};
NS_NAMED_LITERAL_STRING(realXSIURI1,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(realXSIURI2,"http://www.w3.org/2001/XMLSchema-instance");
const nsAString* nsSOAPUtils::kXSIURI[] = {&realXSIURI1, &realXSIURI2};
NS_NAMED_LITERAL_STRING(realXSIURI1,
"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(realXSIURI2,
"http://www.w3.org/2001/XMLSchema-instance");
const nsAString *nsSOAPUtils::kXSIURI[] = { &realXSIURI1, &realXSIURI2
};
NS_NAMED_LITERAL_STRING(realXSURI1,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(realXSURI2,"http://www.w3.org/2001/XMLSchema");
const nsAString* nsSOAPUtils::kXSURI[] = {&realXSURI1, &realXSURI2};
NS_NAMED_LITERAL_STRING(realXSURI1, "http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(realXSURI2, "http://www.w3.org/2001/XMLSchema");
const nsAString *nsSOAPUtils::kXSURI[] = { &realXSURI1, &realXSURI2
};
NS_NAMED_LITERAL_STRING(realSOAPEnvPrefix,"env");
const nsAString& nsSOAPUtils::kSOAPEnvPrefix = realSOAPEnvPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEnvPrefix, "env");
const nsAString & nsSOAPUtils::kSOAPEnvPrefix = realSOAPEnvPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEncPrefix,"enc");
const nsAString& nsSOAPUtils::kSOAPEncPrefix = realSOAPEncPrefix;
NS_NAMED_LITERAL_STRING(realSOAPEncPrefix, "enc");
const nsAString & nsSOAPUtils::kSOAPEncPrefix = realSOAPEncPrefix;
NS_NAMED_LITERAL_STRING(realXSIPrefix,"xsi");
const nsAString& nsSOAPUtils::kXSIPrefix = realXSIPrefix;
NS_NAMED_LITERAL_STRING(realXSIPrefix, "xsi");
const nsAString & nsSOAPUtils::kXSIPrefix = realXSIPrefix;
NS_NAMED_LITERAL_STRING(realXSITypeAttribute,"type");
const nsAString& nsSOAPUtils::kXSITypeAttribute = realXSITypeAttribute;
NS_NAMED_LITERAL_STRING(realXSITypeAttribute, "type");
const nsAString & nsSOAPUtils::kXSITypeAttribute = realXSITypeAttribute;
NS_NAMED_LITERAL_STRING(realXSPrefix,"xs");
const nsAString& nsSOAPUtils::kXSPrefix = realXSPrefix;
NS_NAMED_LITERAL_STRING(realXSPrefix, "xs");
const nsAString & nsSOAPUtils::kXSPrefix = realXSPrefix;
NS_NAMED_LITERAL_STRING(realEncodingStyleAttribute,"encodingStyle");
const nsAString& nsSOAPUtils::kEncodingStyleAttribute = realEncodingStyleAttribute;
NS_NAMED_LITERAL_STRING(realEncodingStyleAttribute, "encodingStyle");
const
nsAString &
nsSOAPUtils::kEncodingStyleAttribute = realEncodingStyleAttribute;
NS_NAMED_LITERAL_STRING(realActorAttribute,"actor");
const nsAString& nsSOAPUtils::kActorAttribute = realActorAttribute;
NS_NAMED_LITERAL_STRING(realActorAttribute, "actor");
const nsAString & nsSOAPUtils::kActorAttribute = realActorAttribute;
NS_NAMED_LITERAL_STRING(realMustUnderstandAttribute,"mustUnderstand");
const nsAString& nsSOAPUtils::kMustUnderstandAttribute = realMustUnderstandAttribute;
NS_NAMED_LITERAL_STRING(realMustUnderstandAttribute, "mustUnderstand");
const
nsAString &
nsSOAPUtils::kMustUnderstandAttribute = realMustUnderstandAttribute;
NS_NAMED_LITERAL_STRING(realEnvelopeTagName,"Envelope");
const nsAString& nsSOAPUtils::kEnvelopeTagName = realEnvelopeTagName;
NS_NAMED_LITERAL_STRING(realEnvelopeTagName, "Envelope");
const nsAString & nsSOAPUtils::kEnvelopeTagName = realEnvelopeTagName;
NS_NAMED_LITERAL_STRING(realHeaderTagName,"Header");
const nsAString& nsSOAPUtils::kHeaderTagName = realHeaderTagName;
NS_NAMED_LITERAL_STRING(realHeaderTagName, "Header");
const nsAString & nsSOAPUtils::kHeaderTagName = realHeaderTagName;
NS_NAMED_LITERAL_STRING(realBodyTagName,"Body");
const nsAString& nsSOAPUtils::kBodyTagName = realBodyTagName;
NS_NAMED_LITERAL_STRING(realBodyTagName, "Body");
const nsAString & nsSOAPUtils::kBodyTagName = realBodyTagName;
NS_NAMED_LITERAL_STRING(realFaultTagName,"Fault");
const nsAString& nsSOAPUtils::kFaultTagName = realFaultTagName;
NS_NAMED_LITERAL_STRING(realFaultTagName, "Fault");
const nsAString & nsSOAPUtils::kFaultTagName = realFaultTagName;
NS_NAMED_LITERAL_STRING(realFaultCodeTagName,"faultcode");
const nsAString& nsSOAPUtils::kFaultCodeTagName = realFaultCodeTagName;
NS_NAMED_LITERAL_STRING(realFaultCodeTagName, "faultcode");
const nsAString & nsSOAPUtils::kFaultCodeTagName = realFaultCodeTagName;
NS_NAMED_LITERAL_STRING(realFaultStringTagName,"faultstring");
const nsAString& nsSOAPUtils::kFaultStringTagName = realFaultStringTagName;
NS_NAMED_LITERAL_STRING(realFaultStringTagName, "faultstring");
const
nsAString & nsSOAPUtils::kFaultStringTagName = realFaultStringTagName;
NS_NAMED_LITERAL_STRING(realFaultActorTagName,"faultactor");
const nsAString& nsSOAPUtils::kFaultActorTagName = realFaultActorTagName;
NS_NAMED_LITERAL_STRING(realFaultActorTagName, "faultactor");
const nsAString & nsSOAPUtils::kFaultActorTagName = realFaultActorTagName;
NS_NAMED_LITERAL_STRING(realFaultDetailTagName,"detail");
const nsAString& nsSOAPUtils::kFaultDetailTagName = realFaultDetailTagName;
NS_NAMED_LITERAL_STRING(realFaultDetailTagName, "detail");
const
nsAString & nsSOAPUtils::kFaultDetailTagName = realFaultDetailTagName;
NS_NAMED_LITERAL_STRING(realEncodingSeparator,"#");
const nsAString& nsSOAPUtils::kEncodingSeparator = realEncodingSeparator;
NS_NAMED_LITERAL_STRING(realEncodingSeparator, "#");
const nsAString & nsSOAPUtils::kEncodingSeparator = realEncodingSeparator;
NS_NAMED_LITERAL_STRING(realQualifiedSeparator,":");
const nsAString& nsSOAPUtils::kQualifiedSeparator = realQualifiedSeparator;
NS_NAMED_LITERAL_STRING(realQualifiedSeparator, ":");
const
nsAString & nsSOAPUtils::kQualifiedSeparator = realQualifiedSeparator;
NS_NAMED_LITERAL_STRING(realXMLNamespaceNamespaceURI, "http://www.w3.org/2000/xmlns/");
const nsAString& nsSOAPUtils::kXMLNamespaceNamespaceURI = realXMLNamespaceNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceNamespaceURI,
"http://www.w3.org/2000/xmlns/");
const nsAString &
nsSOAPUtils::kXMLNamespaceNamespaceURI = realXMLNamespaceNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceURI, "http://www.w3.org/XML/1998/namespace");
const nsAString& nsSOAPUtils::kXMLNamespaceURI = realXMLNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLNamespaceURI,
"http://www.w3.org/XML/1998/namespace");
const
nsAString & nsSOAPUtils::kXMLNamespaceURI = realXMLNamespaceURI;
NS_NAMED_LITERAL_STRING(realXMLPrefix, "xml:");
const nsAString& nsSOAPUtils::kXMLPrefix = realXMLPrefix;
const nsAString & nsSOAPUtils::kXMLPrefix = realXMLPrefix;
NS_NAMED_LITERAL_STRING(realXMLNamespacePrefix, "xmlns:");
const nsAString& nsSOAPUtils::kXMLNamespacePrefix = realXMLNamespacePrefix;
const
nsAString & nsSOAPUtils::kXMLNamespacePrefix = realXMLNamespacePrefix;
NS_NAMED_LITERAL_STRING(realTrue, "true");
const nsAString& nsSOAPUtils::kTrue = realTrue;
const nsAString & nsSOAPUtils::kTrue = realTrue;
NS_NAMED_LITERAL_STRING(realFalse, "false");
const nsAString& nsSOAPUtils::kFalse = realFalse;
const nsAString & nsSOAPUtils::kFalse = realFalse;
NS_NAMED_LITERAL_STRING(realTrueA, "1");
const nsAString& nsSOAPUtils::kTrueA = realTrueA;
const nsAString & nsSOAPUtils::kTrueA = realTrueA;
NS_NAMED_LITERAL_STRING(realFalseA, "0");
const nsAString& nsSOAPUtils::kFalseA = realFalseA;
const nsAString & nsSOAPUtils::kFalseA = realFalseA;
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement)
void nsSOAPUtils::GetSpecificChildElement(nsIDOMElement * aParent,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
nsCOMPtr < nsIDOMElement > sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
if (sibling) {
GetSpecificSiblingElement(sibling, aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement)
void nsSOAPUtils::GetSpecificSiblingElement(nsIDOMElement * aSibling,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
nsCOMPtr < nsIDOMElement > sibling;
*aElement = nsnull;
sibling = aSibling;
@ -153,23 +171,21 @@ nsSOAPUtils::GetSpecificSiblingElement(
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(aNamespace))
{
if (name.Equals(aType) && namespaceURI.Equals(aNamespace)) {
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
nsCOMPtr < nsIDOMElement > temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
void nsSOAPUtils::GetFirstChildElement(nsIDOMElement * aParent,
nsIDOMElement ** aElement)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
@ -177,19 +193,18 @@ nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void **) aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
void nsSOAPUtils::GetNextSiblingElement(nsIDOMElement * aStart,
nsIDOMElement ** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
nsCOMPtr < nsIDOMNode > sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
@ -197,45 +212,44 @@ nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
sibling->QueryInterface(NS_GET_IID(nsIDOMElement),
(void **) aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
nsCOMPtr < nsIDOMNode > temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAString& aText)
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement * aElement,
nsAString & aText)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr < nsIDOMText > text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
} else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
PRBool nsSOAPUtils::HasChildElements(nsIDOMElement * aElement)
{
nsCOMPtr<nsIDOMNode> child;
nsCOMPtr < nsIDOMNode > child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
@ -244,18 +258,18 @@ nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
nsCOMPtr < nsIDOMNode > temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
void nsSOAPUtils::GetNextSibling(nsIDOMNode * aSibling,
nsIDOMNode ** aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
nsCOMPtr < nsIDOMNode > last;
nsCOMPtr < nsIDOMNode > current;
PRUint16 type;
*aNext = nsnull;
@ -264,23 +278,19 @@ nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
if (!last) {
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
} else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
while (!current) {
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
} else {
current = nsnull;
break;
}
@ -288,9 +298,11 @@ nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAString & aQName,
nsAString & aURI)
nsresult
nsSOAPUtils::GetNamespaceURI(nsIDOMElement * aScope,
const nsAString & aQName,
nsAString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
@ -306,41 +318,46 @@ nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsCOMPtr < nsIDOMNode > current = aScope;
nsCOMPtr < nsIDOMNamedNodeMap > attrs;
nsCOMPtr < nsIDOMNode > temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix,
getter_AddRefs(temp));
if (NS_FAILED(rc))
return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAString & aQName,
nsAString & aLocalName)
nsresult
nsSOAPUtils::GetLocalName(const nsAString & aQName,
nsAString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i+1, aQName.Length() - i);
aQName.Mid(aLocalName, i + 1, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAString & aURI,
nsAString & aPrefix)
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement * aScope,
const nsAString & aURI,
nsAString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
@ -351,60 +368,65 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsCOMPtr < nsIDOMNode > current = aScope;
nsCOMPtr < nsIDOMNamedNodeMap > attrs;
nsCOMPtr < nsIDOMNode > temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (NS_FAILED(rc))
return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
for (;;) {
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc))
return rc;
nsCOMPtr < nsIDOMNode > check = aScope;
PRBool hasDecl;
nsCOMPtr < nsIDOMElement > echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
rc = echeck->
HasAttributeNS(nsSOAPUtils::
kXMLNamespaceNamespaceURI, prefix,
&hasDecl);
if (NS_FAILED(rc))
return rc;
if (hasDecl)
break;
echeck->GetParentNode(getter_AddRefs(check));
break;
echeck->GetParentNode(getter_AddRefs(check));
}
}
if (check == current) {
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
else { // Decode the generated namespace into a number
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
@ -418,7 +440,7 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
maxns = n;
}
}
}
@ -437,14 +459,14 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
nsWritingIterator < PRUnichar > i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
*i2 = (PRUnichar) (r + '0');
}
i2--;
*i2 = 's';
@ -453,22 +475,23 @@ nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAString& aSuper,
nsAString& aSub)
PRBool nsSOAPUtils::StartsWith(nsAString & aSuper, nsAString & aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
if (c1 < c2)
return PR_FALSE;
if (c1 == c2)
return aSuper.Equals(aSub);
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
if (*i1 != *i2)
return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@ -28,79 +28,77 @@
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAString& aNamespace,
const nsAString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetSpecificChildElement(nsIDOMElement * aParent,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement * aSibling,
const nsAString & aNamespace,
const nsAString & aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement * aParent,
nsIDOMElement ** aElement);
static void GetNextSiblingElement(nsIDOMElement * aStart,
nsIDOMElement ** aElement);
static nsresult GetElementTextContent(nsIDOMElement * aElement,
nsAString & aText);
static PRBool HasChildElements(nsIDOMElement * aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAString & aURI,
nsAString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAString & aQName,
nsAString & aURI);
static nsresult GetLocalName(const nsAString & aQName,
nsAString & aLocalName);
static void GetNextSibling(nsIDOMNode * aSibling, nsIDOMNode ** aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement * aElement,
const nsAString & aURI,
nsAString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement * aElement,
const nsAString & aQName,
nsAString & aURI);
static nsresult GetLocalName(const nsAString & aQName,
nsAString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAString& aSuper,
nsAString& aSub);
static const nsAString* kSOAPEnvURI[];
static const nsAString* kSOAPEncURI[];
static const nsAString* kXSIURI[];
static const nsAString* kXSURI[];
static PRBool StartsWith(nsAString & aSuper, nsAString & aSub);
static const nsAString& kSOAPEnvPrefix;
static const nsAString& kSOAPEncPrefix;
static const nsAString& kXSIPrefix;
static const nsAString& kXSITypeAttribute;
static const nsAString& kXSPrefix;
static const nsAString& kEncodingStyleAttribute;
static const nsAString& kActorAttribute;
static const nsAString& kMustUnderstandAttribute;
static const nsAString& kEnvelopeTagName;
static const nsAString& kHeaderTagName;
static const nsAString& kBodyTagName;
static const nsAString& kFaultTagName;
static const nsAString& kFaultCodeTagName;
static const nsAString& kFaultStringTagName;
static const nsAString& kFaultActorTagName;
static const nsAString& kFaultDetailTagName;
static const nsAString& kEncodingSeparator;
static const nsAString& kQualifiedSeparator;
static const nsAString& kXMLNamespaceNamespaceURI;
static const nsAString& kXMLNamespaceURI;
static const nsAString& kXMLNamespacePrefix;
static const nsAString& kXMLPrefix;
static const nsAString& kTrue;
static const nsAString& kTrueA;
static const nsAString& kFalse;
static const nsAString& kFalseA;
} ;
static const nsAString *kSOAPEnvURI[];
static const nsAString *kSOAPEncURI[];
static const nsAString *kXSIURI[];
static const nsAString *kXSURI[];
static const nsAString & kSOAPEnvPrefix;
static const nsAString & kSOAPEncPrefix;
static const nsAString & kXSIPrefix;
static const nsAString & kXSITypeAttribute;
static const nsAString & kXSPrefix;
static const nsAString & kEncodingStyleAttribute;
static const nsAString & kActorAttribute;
static const nsAString & kMustUnderstandAttribute;
static const nsAString & kEnvelopeTagName;
static const nsAString & kHeaderTagName;
static const nsAString & kBodyTagName;
static const nsAString & kFaultTagName;
static const nsAString & kFaultCodeTagName;
static const nsAString & kFaultStringTagName;
static const nsAString & kFaultActorTagName;
static const nsAString & kFaultDetailTagName;
static const nsAString & kEncodingSeparator;
static const nsAString & kQualifiedSeparator;
static const nsAString & kXMLNamespaceNamespaceURI;
static const nsAString & kXMLNamespaceURI;
static const nsAString & kXMLNamespacePrefix;
static const nsAString & kXMLPrefix;
static const nsAString & kTrue;
static const nsAString & kTrueA;
static const nsAString & kFalse;
static const nsAString & kFalseA;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAString& aString)
inline PRBool AStringIsNull(const nsAString & aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAString& aString)
inline void SetAStringToNull(nsAString & aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
@ -109,7 +107,9 @@ inline void SetAStringToNull(nsAString& aString)
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
inline void SOAPEncodingKey(const nsAString& aURI, const nsAString& aType, nsAString& result)
inline void
SOAPEncodingKey(const nsAString & aURI, const nsAString & aType,
nsAString & result)
{
result.Assign(aURI);
result.Append(nsSOAPUtils::kEncodingSeparator);