1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include "nsSOAPFault.h"
39 #include "nsSOAPUtils.h"
40 #include "nsIDOMNodeList.h"
41 #include "nsISOAPMessage.h"
42 #include "nsSOAPException.h"
43 #include "nsIClassInfoImpl.h"
45 nsSOAPFault::nsSOAPFault()
49 nsSOAPFault::~nsSOAPFault()
53 NS_IMPL_ISUPPORTS1_CI(nsSOAPFault
, nsISOAPFault
)
54 /* attribute nsIDOMElement element; */
55 NS_IMETHODIMP
nsSOAPFault::SetElement(nsIDOMElement
* aElement
)
58 nsAutoString namespaceURI
;
60 nsresult rc
= aElement
->GetNamespaceURI(namespaceURI
);
63 rc
= aElement
->GetLocalName(name
);
66 if (name
.Equals(gSOAPStrings
->kFaultTagName
)) {
68 Equals(*gSOAPStrings
->kSOAPEnvURI
[nsISOAPMessage::VERSION_1_2
])) {
69 mVersion
= nsISOAPMessage::VERSION_1_2
;
70 } else if (namespaceURI
.
71 Equals(*gSOAPStrings
->kSOAPEnvURI
[nsISOAPMessage::VERSION_1_1
])) {
72 mVersion
= nsISOAPMessage::VERSION_1_1
;
74 return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE
,"SOAP_BADFAULT", "Cannot recognize SOAP version from namespace URI of fault");
77 return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE
,"SOAP_BADFAULT", "Cannot recognize element tag of fault.");
80 mFaultElement
= aElement
;
84 NS_IMETHODIMP
nsSOAPFault::GetElement(nsIDOMElement
* *aElement
)
86 NS_ENSURE_ARG_POINTER(aElement
);
87 *aElement
= mFaultElement
;
88 NS_IF_ADDREF(*aElement
);
92 /* readonly attribute wstring faultCode; */
93 NS_IMETHODIMP
nsSOAPFault::GetFaultCode(nsAString
& aFaultCode
)
96 return NS_ERROR_ILLEGAL_VALUE
;
97 aFaultCode
.Truncate();
98 nsCOMPtr
<nsIDOMElement
> faultcode
;
99 nsSOAPUtils::GetSpecificChildElement(nsnull
, mFaultElement
,
100 gSOAPStrings
->kEmpty
,
101 gSOAPStrings
->kFaultCodeTagName
,
102 getter_AddRefs(faultcode
));
104 nsAutoString combined
;
105 nsresult rc
= nsSOAPUtils::GetElementTextContent(faultcode
, combined
);
108 return nsSOAPUtils::GetLocalName(combined
, aFaultCode
);
113 /* readonly attribute wstring faultNamespaceURI; */
114 NS_IMETHODIMP
nsSOAPFault::GetFaultNamespaceURI(nsAString
& aNamespaceURI
)
117 return NS_ERROR_ILLEGAL_VALUE
;
118 aNamespaceURI
.Truncate();
119 nsCOMPtr
<nsIDOMElement
> faultcode
;
120 nsSOAPUtils::GetSpecificChildElement(nsnull
, mFaultElement
,
121 gSOAPStrings
->kEmpty
,
122 gSOAPStrings
->kFaultCodeTagName
,
123 getter_AddRefs(faultcode
));
125 nsAutoString combined
;
126 nsresult rc
= nsSOAPUtils::GetElementTextContent(faultcode
, combined
);
129 return nsSOAPUtils::GetNamespaceURI(nsnull
, faultcode
, combined
, aNamespaceURI
);
134 /* readonly attribute wstring faultString; */
135 NS_IMETHODIMP
nsSOAPFault::GetFaultString(nsAString
& aFaultString
)
138 return NS_ERROR_ILLEGAL_VALUE
;
140 aFaultString
.Truncate();
141 nsCOMPtr
<nsIDOMElement
> element
;
142 nsSOAPUtils::GetSpecificChildElement(nsnull
, mFaultElement
,
143 gSOAPStrings
->kEmpty
,
144 gSOAPStrings
->kFaultStringTagName
,
145 getter_AddRefs(element
));
147 nsresult rc
= nsSOAPUtils::GetElementTextContent(element
, aFaultString
);
154 /* readonly attribute wstring faultActor; */
155 NS_IMETHODIMP
nsSOAPFault::GetFaultActor(nsAString
& aFaultActor
)
158 return NS_ERROR_ILLEGAL_VALUE
;
160 aFaultActor
.Truncate();
161 nsCOMPtr
<nsIDOMElement
> element
;
162 nsSOAPUtils::GetSpecificChildElement(nsnull
, mFaultElement
,
163 gSOAPStrings
->kEmpty
,
164 gSOAPStrings
->kFaultActorTagName
,
165 getter_AddRefs(element
));
167 nsresult rc
= nsSOAPUtils::GetElementTextContent(element
, aFaultActor
);
174 /* readonly attribute nsIDOMElement detail; */
175 NS_IMETHODIMP
nsSOAPFault::GetDetail(nsIDOMElement
* *aDetail
)
177 NS_ENSURE_ARG_POINTER(aDetail
);
179 return NS_ERROR_ILLEGAL_VALUE
;
181 nsSOAPUtils::GetSpecificChildElement(nsnull
, mFaultElement
,
182 gSOAPStrings
->kEmpty
,
183 gSOAPStrings
->kFaultDetailTagName
,