You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2007/03/07 17:20:27 UTC
svn commit: r515633 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java
saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
Author: ruchithf
Date: Wed Mar 7 08:20:25 2007
New Revision: 515633
URL: http://svn.apache.org/viewvc?view=rev&rev=515633
Log:
getting some more jaxws tests to work... still a few more to go :-(
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java
webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java?view=diff&rev=515633&r1=515632&r2=515633
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java Wed Mar 7 08:20:25 2007
@@ -429,19 +429,29 @@
// </env:Fault>
// </env:Body>
// </env:Envelope>
+
+ boolean isSoap11 = soapFault.getNamespace().getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
// Set the primary Code Value
SOAPFaultCode soapCode = factory.createSOAPFaultCode(soapFault);
- SOAPFaultValue soapValue = factory.createSOAPFaultValue(soapCode);
QName soapValueQName = xmlFault.getCode().toQName(ns.getNamespaceURI());
- soapValue.setText(soapValueQName);
+ if(isSoap11) {
+ soapCode.setText(soapValueQName);
+ } else {
+ SOAPFaultValue soapValue = factory.createSOAPFaultValue(soapCode);
+ soapValue.setText(soapValueQName);
+ }
// Set the primary Reason Text
SOAPFaultReason soapReason = factory.createSOAPFaultReason(soapFault);
- SOAPFaultText soapText = factory.createSOAPFaultText(soapReason);
- soapText.setText(xmlFault.getReason().getText());
- soapText.setLang(xmlFault.getReason().getLang());
+ if(isSoap11) {
+ soapReason.setText(xmlFault.getReason().getText());
+ } else {
+ SOAPFaultText soapText = factory.createSOAPFaultText(soapReason);
+ soapText.setText(xmlFault.getReason().getText());
+ soapText.setLang(xmlFault.getReason().getLang());
+ }
// Set the Detail and contents of Detail
Block[] blocks = xmlFault.getDetailBlocks();
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java?view=diff&rev=515633&r1=515632&r2=515633
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/utility/SimpleServer.java Wed Mar 7 08:20:25 2007
@@ -33,6 +33,7 @@
public void init() {
repositoryDir = System.getProperty("basedir",".")+"/"+System.getProperty("build.repository");
+// repositoryDir = "target/test-classes";
System.out.println(">> repositoryDir = " + repositoryDir);
String axis2xml = System.getProperty("axis2.config");
Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java?view=diff&rev=515633&r1=515632&r2=515633
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java (original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java Wed Mar 7 08:20:25 2007
@@ -36,6 +36,7 @@
import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
import org.apache.axiom.om.impl.dom.ElementImpl;
import org.apache.axiom.om.impl.dom.NodeImpl;
+import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultDetail;
@@ -88,29 +89,36 @@
* @see setFaultCode(Name), getFaultCode(),SOAPElement.addNamespaceDeclaration(String, String)
*/
public void setFaultCode(String faultCode) throws SOAPException {
- org.apache.axiom.soap.SOAPFactory soapFactory = null;
-
- //It must be of the form "prefix:localName" where the prefix has been defined in a
- //namespace declaration.
- if(faultCode.indexOf(":") == -1){
- throw new SOAPException("faultCode must be of the form prefix:localName");
- }else{
- String prefix,localName ="";
- prefix = faultCode.substring(0, faultCode.indexOf(":"));
- localName = faultCode.substring(faultCode.indexOf(":")+1);
- }
-
- if(this.element.getOMFactory() instanceof SOAP11Factory){
- soapFactory = DOOMAbstractFactory.getSOAP11Factory();
- }
- else if(this.element.getOMFactory() instanceof SOAP12Factory){
- soapFactory = DOOMAbstractFactory.getSOAP12Factory();
- }
-
- SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(fault);
- SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
- soapFaultCode.setValue(soapFaultValue);
- soapFaultValue.setText(faultCode);
+ org.apache.axiom.soap.SOAPFactory soapFactory = null;
+ boolean isSoap11 = this.element.getNamespace().getNamespaceURI()
+ .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ //It must be of the form "prefix:localName" where the prefix has been defined in a
+ //namespace declaration.
+ if(faultCode.indexOf(":") == -1){
+ throw new SOAPException("faultCode must be of the form prefix:localName");
+ }else{
+ String prefix,localName ="";
+ prefix = faultCode.substring(0, faultCode.indexOf(":"));
+ localName = faultCode.substring(faultCode.indexOf(":")+1);
+ }
+
+ if(isSoap11){
+ soapFactory = DOOMAbstractFactory.getSOAP11Factory();
+ } else {
+ soapFactory = DOOMAbstractFactory.getSOAP12Factory();
+ }
+
+ SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode(fault);
+
+ if(isSoap11) {
+ soapFaultCode.setText(faultCode);
+ } else {
+ SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
+ soapFaultCode.setValue(soapFaultValue);
+ soapFaultValue.setText(faultCode);
+ }
+
this.fault.setCode(soapFaultCode);
}
@@ -188,48 +196,49 @@
* @see #getFaultString() getFaultString()
*/
public void setFaultString(String faultString) throws SOAPException {
+
+ boolean isSoap11 = this.element.getNamespace().getNamespaceURI()
+ .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
if (this.fault.getReason() != null) {
SOAPFaultReason reason = this.fault.getReason();
- if (reason.getFirstSOAPText() != null) {
- reason.getFirstSOAPText().getFirstOMChild().detach();
- reason.getFirstSOAPText().setText(faultString);
- }
- else
- {
- SOAPFaultText text = null;
- if(this.element.getOMFactory() instanceof SOAP11Factory){
- text = new SOAP11FaultTextImpl(reason,
- (SOAPFactory) this.element.getOMFactory());
- }else if(this.element.getOMFactory() instanceof SOAP12Factory){
- text = new SOAP12FaultTextImpl(reason,
+ if(isSoap11) {
+ reason.setText(faultString);
+ } else {
+ if (reason.getFirstSOAPText() != null) {
+ reason.getFirstSOAPText().getFirstOMChild().detach();
+ reason.getFirstSOAPText().setText(faultString);
+ } else {
+ SOAPFaultText text = new SOAP12FaultTextImpl(reason,
(SOAPFactory) this.element.getOMFactory());
- }
- text.setText(faultString);
- reason.addSOAPText(text);
+ text.setText(faultString);
+ reason.addSOAPText(text);
+ }
}
- }
- else
- {
- org.apache.axiom.soap.SOAPFactory soapFactory = null;
-
- if(this.element.getOMFactory() instanceof SOAP11Factory){
- soapFactory = (SOAP11Factory)this.element.getOMFactory();
- }
- else if(this.element.getOMFactory() instanceof SOAP12Factory){
- soapFactory = (SOAP12Factory)this.element.getOMFactory();
- }
+ } else {
+ org.apache.axiom.soap.SOAPFactory soapFactory = (SOAPFactory)this.element.getOMFactory();
SOAPFaultReason faultReason = soapFactory.createSOAPFaultReason(fault);
- SOAPFaultText faultText = soapFactory.createSOAPFaultText(faultReason);
- faultText.setText(faultString);
- }
+ if(isSoap11) {
+ faultReason.setText(faultString);
+ } else {
+ SOAPFaultText faultText = soapFactory.createSOAPFaultText(faultReason);
+ faultText.setText(faultString);
+ }
+ }
}
/* (non-Javadoc)
* @see javax.xml.soap.SOAPFault#getFaultString()
*/
public String getFaultString() {
- if (this.fault.getReason() != null && this.fault.getReason().getFirstSOAPText() != null) {
- return this.fault.getReason().getFirstSOAPText().getText();
+
+ if (this.fault.getNamespace().getNamespaceURI().equals(
+ SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+ return this.fault.getReason().getText();
+ } else {
+ if (this.fault.getReason() != null && this.fault.getReason().getFirstSOAPText() != null) {
+ return this.fault.getReason().getFirstSOAPText().getText();
+ }
}
return null;
}
@@ -264,9 +273,9 @@
*
*/
public void setFaultCode(Name faultCodeQName) throws SOAPException {
- if(faultCodeQName.getURI() == null || faultCodeQName.getURI().trim().length() == 0){
- throw new SOAPException("faultCodeQName must be namespace qualified.");
- }
+ if(faultCodeQName.getURI() == null || faultCodeQName.getURI().trim().length() == 0){
+ throw new SOAPException("faultCodeQName must be namespace qualified.");
+ }
this.faultCodeName = faultCodeQName;
}
@@ -316,39 +325,32 @@
//TODO : check the implementation
public void setFaultString(String faultString, Locale locale) throws SOAPException {
+ boolean isSoap11 = this.element.getNamespace().getNamespaceURI()
+ .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
if (this.fault.getReason() != null) {
SOAPFaultReason reason = this.fault.getReason();
- if (reason.getFirstSOAPText() != null) {
- reason.getFirstSOAPText().setText(faultString);
- reason.getFirstSOAPText().setLang(locale.toString());
+ if(isSoap11) {
+ reason.setText(faultString);
} else {
- SOAPFaultText text = null;
- if(this.element.getOMFactory() instanceof SOAP11Factory){
- text = new SOAP11FaultTextImpl(reason,
- (SOAPFactory) this.element.getOMFactory());
- text.setText(faultString);
- text.setLang(locale.toString());
- reason.addSOAPText(text);
-
- }else if(this.element.getOMFactory() instanceof SOAP12Factory){
- addFaultReasonText(faultString, locale);
- }
+ if (reason.getFirstSOAPText() != null) {
+ reason.getFirstSOAPText().setText(faultString);
+ reason.getFirstSOAPText().setLang(locale.toString());
+ } else {
+ addFaultReasonText(faultString, locale);
+ }
}
+
} else {
- if(this.element.getOMFactory() instanceof SOAP11Factory){
+
+ if(isSoap11) {
SOAPFaultReason reason = new SOAP11FaultReasonImpl(this.fault,
(SOAPFactory) this.element.getOMFactory());
- SOAPFaultText text = new SOAP11FaultTextImpl(reason,
- (SOAPFactory) this.element.getOMFactory());
- text.setText(faultString);
- text.setLang(locale.toString());
- reason.addSOAPText(text);
- this.fault.setReason(reason);
-
- }else if(this.element.getOMFactory() instanceof SOAP12Factory){
- addFaultReasonText(faultString, locale);
- }
-
+ reason.setText(faultString);
+ }else if(this.element.getOMFactory() instanceof SOAP12Factory){
+ addFaultReasonText(faultString, locale);
+ }
+
}
this.faultReasonLocale = locale;
}
@@ -507,24 +509,35 @@
* <p/>
*/
public QName getFaultCodeAsQName() {
- SOAPFaultCode soapFaultCode = this.fault.getCode();
- if(soapFaultCode != null){
+ boolean isSoap11 = this.element.getNamespace().getNamespaceURI()
+ .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ SOAPFaultCode soapFaultCode = this.fault.getCode();
+ if (soapFaultCode != null) {
String prefix = "";
String localPart = "";
String uri = "";
- String text = soapFaultCode.getValue().getText();
-
+ String text = "";
+ if(isSoap11) {
+ text = soapFaultCode.getText();
+ } else {
+ text = soapFaultCode.getValue().getText();
+ }
+
prefix = text.substring(0, text.indexOf(":"));
- localPart = text.substring(text.indexOf(":")+1);
- OMNamespace namespace = soapFaultCode.getValue().getNamespace();
- if (namespace != null) {
- uri = soapFaultCode.getValue().getNamespace().getNamespaceURI();
+ localPart = text.substring(text.indexOf(":") + 1);
+ if(isSoap11) {
+ uri = fault.findNamespaceURI(prefix).getNamespaceURI();
} else {
- uri = this.fault.getNamespace().getNamespaceURI();
+ OMNamespace namespace = soapFaultCode.getValue().getNamespace();
+ if (namespace != null) {
+ uri = soapFaultCode.getValue().getNamespace().getNamespaceURI();
+ } else {
+ uri = this.fault.getNamespace().getNamespaceURI();
+ }
}
-
- QName qname = new QName(uri,localPart,prefix);
- return qname;
+
+ QName qname = new QName(uri, localPart, prefix);
+ return qname;
}
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org