1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#include "nsSOAPFault.h"
40
#include "nsSOAPUtils.h"
41
#include "nsIDOMNodeList.h"
42
#include "nsISOAPMessage.h"
43
#include "nsSOAPException.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)
95
NS_ENSURE_ARG_POINTER(&aFaultCode);
97
return NS_ERROR_ILLEGAL_VALUE;
98
aFaultCode.Truncate();
99
nsCOMPtr < nsIDOMElement > faultcode;
100
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
101
gSOAPStrings->kEmpty,
102
gSOAPStrings->kFaultCodeTagName,
103
getter_AddRefs(faultcode));
105
nsAutoString combined;
106
nsresult rc = nsSOAPUtils::GetElementTextContent(faultcode, combined);
109
return nsSOAPUtils::GetLocalName(combined, aFaultCode);
114
/* readonly attribute wstring faultNamespaceURI; */
115
NS_IMETHODIMP nsSOAPFault::GetFaultNamespaceURI(nsAString & aNamespaceURI)
117
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
119
return NS_ERROR_ILLEGAL_VALUE;
120
aNamespaceURI.Truncate();
121
nsCOMPtr < nsIDOMElement > faultcode;
122
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
123
gSOAPStrings->kEmpty,
124
gSOAPStrings->kFaultCodeTagName,
125
getter_AddRefs(faultcode));
127
nsAutoString combined;
128
nsresult rc = nsSOAPUtils::GetElementTextContent(faultcode, combined);
131
return nsSOAPUtils::GetNamespaceURI(nsnull, faultcode, combined, aNamespaceURI);
136
/* readonly attribute wstring faultString; */
137
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAString & aFaultString)
139
NS_ENSURE_ARG_POINTER(&aFaultString);
141
return NS_ERROR_ILLEGAL_VALUE;
143
aFaultString.Truncate();
144
nsCOMPtr < nsIDOMElement > element;
145
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
146
gSOAPStrings->kEmpty,
147
gSOAPStrings->kFaultStringTagName,
148
getter_AddRefs(element));
150
nsresult rc = nsSOAPUtils::GetElementTextContent(element, aFaultString);
157
/* readonly attribute wstring faultActor; */
158
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAString & aFaultActor)
160
NS_ENSURE_ARG_POINTER(&aFaultActor);
162
return NS_ERROR_ILLEGAL_VALUE;
164
aFaultActor.Truncate();
165
nsCOMPtr < nsIDOMElement > element;
166
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
167
gSOAPStrings->kEmpty,
168
gSOAPStrings->kFaultActorTagName,
169
getter_AddRefs(element));
171
nsresult rc = nsSOAPUtils::GetElementTextContent(element, aFaultActor);
178
/* readonly attribute nsIDOMElement detail; */
179
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
181
NS_ENSURE_ARG_POINTER(aDetail);
183
return NS_ERROR_ILLEGAL_VALUE;
185
nsSOAPUtils::GetSpecificChildElement(nsnull, mFaultElement,
186
gSOAPStrings->kEmpty,
187
gSOAPStrings->kFaultDetailTagName,