antelder 2002/11/15 01:31:58
Modified: java/src/org/apache/wsif/util WSIFUtils.java
java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFJmsTransport.java
java/src/org/apache/wsif/base WSIFClientProxy.java
java/test/util WSIFTestRunner.java
Added: java/test/docStyle/wsifservice zipCodeLocal.wsdl
zipCode.wsdl ZipCodeResolverSoap.java
java/test/docStyle ZipCodeAxisTest.java
Log:
First cut at adding document style support to the wsif axis provider
Revision Changes Path
1.1 xml-axis-wsif/java/test/docStyle/wsifservice/zipCodeLocal.wsdl
Index: zipCodeLocal.wsdl
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s0="http://webservices.eraserver.net/"
targetNamespace="http://webservices.eraserver.net/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/" >
<types>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://webservices.eraserver.net/">
<s:element name="ShortZipCode">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="accessCode" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="address" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="city" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="state" nillable="true"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ShortZipCodeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ShortZipCodeResult"
nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string" />
<s:element name="USPSAddress" type="s:string" />
</s:schema>
</types>
<message name="ShortZipCodeSoapIn">
<part name="parameters" element="s0:ShortZipCode" />
</message>
<message name="ShortZipCodeSoapOut">
<part name="parameters" element="s0:ShortZipCodeResponse" />
</message>
<portType name="ZipCodeResolverSoap">
<operation name="ShortZipCode">
<documentation>Given a valid street address, city, and state, returns the ZIP
code in NNNNN format. If an error occurs, returns 00000 instead. Use accessCode of '0'
or '9999' for testing.</documentation>
<input message="s0:ShortZipCodeSoapIn" />
<output message="s0:ShortZipCodeSoapOut" />
</operation>
</portType>
<binding name="ZipCodeResolverSoap" type="s0:ZipCodeResolverSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"
/>
<operation name="ShortZipCode">
<soap:operation soapAction="http://webservices.eraserver.net/ShortZipCode"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="ZipCodeResolver">
<documentation>Given a valid street address, city, and state, this service
returns the proper ZIP code, ZIP code+4, or USPS corrected address. NOTE: This service
is meant for non-commercial, personal use only.</documentation>
<port name="ZipCodeResolverSoap" binding="s0:ZipCodeResolverSoap">
<!-- <soap:address
location="http://webservices.eraserver.net/zipcoderesolver/zipcoderesolver.asmx" />
-->
<soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/>
</port>
</service>
</definitions>
1.1 xml-axis-wsif/java/test/docStyle/wsifservice/zipCode.wsdl
Index: zipCode.wsdl
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s0="http://webservices.eraserver.net/"
targetNamespace="http://webservices.eraserver.net/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/" >
<types>
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://webservices.eraserver.net/">
<s:element name="ShortZipCode">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="accessCode" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="address" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="city" nillable="true"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="state" nillable="true"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ShortZipCodeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ShortZipCodeResult"
nillable="true" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string" />
<s:element name="USPSAddress" type="s:string" />
</s:schema>
</types>
<message name="ShortZipCodeSoapIn">
<part name="parameters" element="s0:ShortZipCode" />
</message>
<message name="ShortZipCodeSoapOut">
<part name="parameters" element="s0:ShortZipCodeResponse" />
</message>
<portType name="ZipCodeResolverSoap">
<operation name="ShortZipCode">
<documentation>Given a valid street address, city, and state, returns the ZIP
code in NNNNN format. If an error occurs, returns 00000 instead. Use accessCode of '0'
or '9999' for testing.</documentation>
<input message="s0:ShortZipCodeSoapIn" />
<output message="s0:ShortZipCodeSoapOut" />
</operation>
</portType>
<binding name="ZipCodeResolverSoap" type="s0:ZipCodeResolverSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"
/>
<operation name="ShortZipCode">
<soap:operation soapAction="http://webservices.eraserver.net/ShortZipCode"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="ZipCodeResolver">
<documentation>Given a valid street address, city, and state, this service
returns the proper ZIP code, ZIP code+4, or USPS corrected address. NOTE: This service
is meant for non-commercial, personal use only.</documentation>
<port name="ZipCodeResolverSoap" binding="s0:ZipCodeResolverSoap">
<soap:address
location="http://webservices.eraserver.net/zipcoderesolver/zipcoderesolver.asmx" />
<!-- <soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/>
-->
</port>
</service>
</definitions>
1.1
xml-axis-wsif/java/test/docStyle/wsifservice/ZipCodeResolverSoap.java
Index: ZipCodeResolverSoap.java
===================================================================
/**
* ZipCodeResolverSoap.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package docStyle.wsifservice;
public interface ZipCodeResolverSoap extends java.rmi.Remote {
/**
* Given a valid street address, city, and state, returns the ZIP code
* in NNNNN format. If an error occurs, returns 00000 instead. Use accessCode
* of '0' or '9999' for testing.
*/
public java.lang.String ShortZipCode(java.lang.String accessCode,
java.lang.String address, java.lang.String city, java.lang.String state) throws
java.rmi.RemoteException;
}
1.22 +124 -5 xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java
Index: WSIFUtils.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- WSIFUtils.java 6 Nov 2002 14:29:16 -0000 1.21
+++ WSIFUtils.java 15 Nov 2002 09:31:57 -0000 1.22
@@ -75,16 +75,11 @@
import java.util.StringTokenizer;
import javax.wsdl.Binding;
-import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Import;
-import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
-import javax.wsdl.OperationType;
-import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.wsdl.PortType;
import javax.wsdl.Service;
@@ -102,6 +97,10 @@
import org.apache.wsif.format.WSIFFormatHandler;
import org.apache.wsif.logging.MessageLogger;
import org.apache.wsif.logging.Trc;
+import org.apache.wsif.schema.ComplexType;
+import org.apache.wsif.schema.ElementType;
+import org.apache.wsif.schema.Parser;
+import org.apache.wsif.schema.SequenceElement;
import org.apache.wsif.wsdl.WSIFWSDLLocatorImpl;
import org.apache.wsif.wsdl.extensions.format.TypeMapping;
import org.w3c.dom.Document;
@@ -109,6 +108,7 @@
import org.xml.sax.InputSource;
import com.ibm.wsdl.Constants;
+import com.ibm.wsdl.PartImpl;
/**
* This class provides utilities for WSIF runtime and generated stubs.
@@ -1282,4 +1282,123 @@
return false; // no more tokens but still some s
}
+ /**
+ * Tests if this is wrapped document literal stype operation.
+ * An operation is wrapped if:
+ * - there is only one input or output message part
+ * and that part is an element not a type
+ * (MIME means there can be many parts, so all this
+ * can check is that there is only one element part)
+ * - the message name is the same as the operation name
+ * (for a response the operation name is appened with "Response")
+ */
+ public static boolean isWrappedDocLiteral(List parts, String operationName) {
+ boolean wrapped = !(parts==null);
+ Part elementPart = null;
+ for (int i = 0; wrapped && i < parts.size(); i++) {
+ Part p = (Part) parts.get(i);
+ if (p.getElementName() != null) {
+ if (elementPart == null) {
+ elementPart = p;
+ String pName = p.getElementName().getLocalPart();
+ if (!operationName.equals(pName)) {
+ wrapped = false;
+ }
+ } else {
+ wrapped = false;
+ }
+ }
+ }
+ return wrapped;
+ }
+
+ /**
+ * Gets the wrapped Part if this is wrapped document literal
+ * stype operation. An operation is wrapped if:
+ * - there is only one input or output message part
+ * and that part is an element not a type
+ * (MIME means there can be many parts, so all this
+ * can check is that there is only one element part)
+ * - the message name is the same as the operation name
+ * (for a response the operation name is appened with "Response")
+ */
+ public static Part getWrappedDocLiteralPart(List parts, String operationName) {
+ boolean wrapped = !(parts==null);
+ Part elementPart = null;
+ for (int i = 0; wrapped && i < parts.size(); i++) {
+ Part p = (Part) parts.get(i);
+ if (p.getElementName() != null) {
+ if (elementPart == null) {
+ elementPart = p;
+ String pName = p.getElementName().getLocalPart();
+ if (!operationName.equals(pName)) {
+ wrapped = false;
+ }
+ } else {
+ wrapped = false;
+ }
+ }
+ }
+ if (!wrapped) {
+ elementPart = null;
+ }
+ return elementPart;
+ }
+
+ /**
+ * Unwraps a wrapped DocLit style part.
+ */
+ public static List unWrapPart(Part p, Definition def) throws WSIFException {
+
+ ArrayList l = new ArrayList();
+ Parser.getAllSchemaTypes(def, l, null);
+ if (l == null || l.size()<1) {
+ throw new WSIFException("no schema elements found");
+ }
+
+ QName partQN = p.getElementName();
+ if (partQN == null) {
+ throw new WSIFException("part has no QName");
+ }
+
+ ElementType et = null;
+ for (int i=0; i<l.size() && et==null; i++ ){
+ Object o = l.get(i);
+ if ( o instanceof ElementType ) {
+ QName etQN = ((ElementType)o).getTypeName();
+ if ( partQN.equals(etQN) ){
+ et = (ElementType)o;
+ }
+ }
+ }
+ if (et == null) {
+ throw new WSIFException("no ElementType found for part: " + p);
+ }
+
+ List children = et.getChildren();
+ if (children == null || l.size()<1) {
+ throw new WSIFException("no ComplexType children on
elementType: " + et);
+ }
+
+ ComplexType ct = (ComplexType) children.get(0);
+ SequenceElement[] se = ct.getSequenceElements();
+ if (se == null || se.length<1) {
+ throw new WSIFException("no sequence elements found on: " +
ct);
+ }
+
+ ArrayList unWrappedParts = new ArrayList();
+ for (int i=0; i< se.length; i++) {
+ PartImpl np = new PartImpl();
+ QName type = se[i].getTypeName();
+ if (type==null) {
+ throw new WSIFException("sequence element has no type name:
" + se[i]);
+ }
+ np.setName(type.getLocalPart());
+ np.setElementName(se[i].getElementType());
+ unWrappedParts.add(np);
+ }
+
+ return unWrappedParts;
+ }
+
}
1.4 +9 -0
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java
Index: WSIFJmsTransport.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFJmsTransport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WSIFJmsTransport.java 15 Oct 2002 12:10:12 -0000 1.3
+++ WSIFJmsTransport.java 15 Nov 2002 09:31:57 -0000 1.4
@@ -62,6 +62,7 @@
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Transport;
+import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.logging.Trc;
import org.apache.wsif.util.jms.WSIFJMSDestination;
@@ -175,6 +176,14 @@
return t;
}
+ public void close() throws WSIFException {
+ Trc.entry(this);
+ if (destination != null) {
+ destination.close();
+ }
+ Trc.exit();
+ }
+
public String deep() {
String buff = "";
try {
1.11 +30 -4 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java
Index: WSIFClientProxy.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFClientProxy.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WSIFClientProxy.java 6 Nov 2002 14:12:35 -0000 1.10
+++ WSIFClientProxy.java 15 Nov 2002 09:31:57 -0000 1.11
@@ -60,6 +60,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -282,7 +283,11 @@
wsifFaultMessage = wsifOperation.createFaultMessage(inputMsgName);
}
- Iterator partIt = inputMessage.getOrderedParts(null).iterator();
+ List inputParts = (inputMessage == null)
+ ? new ArrayList()
+ : inputMessage.getOrderedParts(null);
+ unWrapIfWrappedDocLit(inputParts, operation.getName());
+ Iterator partIt = inputParts.iterator();
int argIndex;
for (argIndex = 0; partIt.hasNext(); argIndex++) {
Part part = (Part) partIt.next();
@@ -315,6 +320,7 @@
Object result = null;
if (outputMessage != null) {
List outputParts = outputMessage.getOrderedParts(null);
+ unWrapIfWrappedDocLit(outputParts, operation.getName()+"Response");
if (outputParts != null && outputParts.size() > 0) {
// The return value is always the first output part
Iterator outPartIt = outputParts.iterator();
@@ -431,8 +437,12 @@
Input input = operation.getInput();
Message inputMessage = (input == null) ? null : input.getMessage();
- int numInputParts =
- inputMessage == null ? 0 : inputMessage.getParts().size();
+ List inputParts = (inputMessage == null)
+ ? new ArrayList()
+ : inputMessage.getOrderedParts(null);
+ unWrapIfWrappedDocLit(inputParts, operation.getName());
+
+ int numInputParts = inputParts.size();
// Check for a match if neither args nor the operation has any
parameters
if (numInputParts == 0 && types.length == 0) {
@@ -445,7 +455,7 @@
continue;
// Go through all the parameters making sure all their datatypes match
- Iterator partIt = inputMessage.getOrderedParts(null).iterator();
+ Iterator partIt = inputParts.iterator();
boolean foundAllArgs = true;
boolean exactMatchAllArgs = true;
for (int argIndex = 0;
@@ -454,6 +464,9 @@
Part part = (Part) partIt.next();
QName partTypeName = part.getTypeName();
+ if (partTypeName==null) {
+ partTypeName = part.getElementName();
+ }
boolean foundThisArg = false;
boolean exactMatchThisArg = false;
@@ -600,6 +613,19 @@
Trc.exit(sb.toString());
return sb.toString();
}
+
+ /**
+ * Unwraps the top level element if this a wrapped message.
+ */
+ private void unWrapIfWrappedDocLit(List parts, String operationName)
+ throws WSIFException {
+ Part p = WSIFUtils.getWrappedDocLiteralPart(parts, operationName);
+ if (p != null) {
+ List unWrappedParts = WSIFUtils.unWrapPart(p, def);
+ parts.remove(p);
+ parts.addAll(unWrappedParts);
+ }
+ }
public String deep() {
String buff = "";
1.1 xml-axis-wsif/java/test/docStyle/ZipCodeAxisTest.java
Index: ZipCodeAxisTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package docStyle;
import java.io.StringReader;
import java.io.StringWriter;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import docStyle.wsifservice.ZipCodeResolverSoap;
import util.TestUtilities;
/**
* Junit test to test out the AXIS provider docstyle support
*/
public class ZipCodeAxisTest extends TestCase {
String wsdlLocation =
TestUtilities.getWsdlPath("java\\test\\docStyle\\wsifservice")
+ "zipCode.wsdl";
// + "zipCodeLocal.wsdl";
public ZipCodeAxisTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
return new TestSuite(ZipCodeAxisTest.class);
}
public void setUp() {
TestUtilities.setUpExtensionsAndProviders();
}
public void testDynamicAxis() {
doitDyn("ZipCodeResolverSoap", "axis");
doitStub("ZipCodeResolverSoap", "axis");
doitMessaging("ZipCodeResolverSoap", "axis");
}
private void doitDyn(String portName, String protocol) {
if (portName.toUpperCase().indexOf("JMS") != -1
&& !TestUtilities.areWeTesting("jms"))
return;
TestUtilities.setProviderForProtocol(protocol);
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://webservices.eraserver.net/",
"ZipCodeResolverSoap");
WSIFPort port = service.getPort(portName);
WSIFOperation operation = port.createOperation("ShortZipCode");
WSIFMessage inMsg = operation.createInputMessage();
WSIFMessage outMsg = operation.createOutputMessage();
WSIFMessage faultMsg = operation.createFaultMessage();
inMsg.setObjectPart("accessCode", "9999");
inMsg.setObjectPart("address", "607 Trinity");
inMsg.setObjectPart("city", "Austin");
inMsg.setObjectPart("state", "TX");
boolean ok =
operation.executeRequestResponseOperation(
inMsg,
outMsg,
faultMsg);
assertTrue("operation returned false!!", ok);
String s = (String) outMsg.getObjectPart("ShortZipCodeResult");
assertTrue("wrong zipcode: " + s + "!!", "78701".equals(s));
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(
"AddressBookTest("
+ portName
+ ") caught exception "
+ ex.getLocalizedMessage(),
false);
}
}
private void doitStub(String portName, String protocol) {
if (portName.toUpperCase().indexOf("JMS") != -1
&& !TestUtilities.areWeTesting("jms"))
return;
TestUtilities.setProviderForProtocol(protocol);
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://webservices.eraserver.net/",
"ZipCodeResolverSoap");
ZipCodeResolverSoap stub = (ZipCodeResolverSoap)
service.getStub(portName, ZipCodeResolverSoap.class);
String zipcode = stub.ShortZipCode( "9999", "607 Trinity", "Austin",
"TX" );
assertTrue("wrong zipcode: " + zipcode + "!!",
"78701".equals(zipcode));
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(
"AddressBookTest("
+ portName
+ ") caught exception "
+ ex.getLocalizedMessage(),
false);
}
}
private void doitMessaging(String portName, String protocol) {
if (portName.toUpperCase().indexOf("JMS") != -1
&& !TestUtilities.areWeTesting("jms"))
return;
TestUtilities.setProviderForProtocol(protocol);
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://webservices.eraserver.net/",
"ZipCodeResolverSoap");
WSIFPort port = service.getPort(portName);
WSIFOperation operation = port.createOperation("ShortZipCode");
WSIFMessage inMsg = operation.createInputMessage();
WSIFMessage outMsg = operation.createOutputMessage();
WSIFMessage faultMsg = operation.createFaultMessage();
String inputDocument =
"<ShortZipCode
xmlns=\"http://webservices.eraserver.net/\">"
+ "<accessCode>9999</accessCode>"
+ "<address>607 Trinity</address>"
+ "<city>Austin</city>"
+ "<state>TX</state>"
+ "</ShortZipCode>";
DOMParser parser = new DOMParser();
String xmlString = "<?xml version=\"1.0\"?>\n" + inputDocument;
parser.parse(new InputSource(new StringReader(xmlString)));
Element element = parser.getDocument().getDocumentElement();
//printElement(element);
inMsg.setObjectPart("parameters", element);
boolean ok =
operation.executeRequestResponseOperation(
inMsg,
outMsg,
faultMsg);
assertTrue("operation returned false!!", ok);
Element responseElement =
(Element) outMsg.getObjectPart("parameters");
assertTrue("return element is null!!", responseElement !=
null);
// printElement(responseElement);
NodeList nl = responseElement.getChildNodes();
Node n = nl.item(0); // "ShortZipCodeResponse"
nl = n.getChildNodes();
n = nl.item(0); // "ShortZipCodeResult"
String s = n.getNodeValue();
if (!"78701".equals(s)) {
printElement(responseElement);
}
assertTrue("wrong zipcode: " + s + "!!", "78701".equals(s));
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(
"AddressBookTest("
+ portName
+ ") caught exception "
+ ex.getLocalizedMessage(),
false);
}
}
private void printElement(Element e) throws Exception {
OutputFormat of = new OutputFormat(e.getOwnerDocument(), "UTF-8",
true);
XMLSerializer xmls = new XMLSerializer(of);
StringWriter sw = new StringWriter();
xmls.setOutputCharStream(sw);
xmls.serialize(e);
System.err.println("element=" + sw.toString());
}
}
1.20 +2 -0 xml-axis-wsif/java/test/util/WSIFTestRunner.java
Index: WSIFTestRunner.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/util/WSIFTestRunner.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WSIFTestRunner.java 11 Nov 2002 15:36:04 -0000 1.19
+++ WSIFTestRunner.java 15 Nov 2002 09:31:57 -0000 1.20
@@ -81,6 +81,7 @@
import addressbook.AddressBookTest;
import async.AsyncTests;
+import docStyle.ZipCodeAxisTest;
/**
* Run JUnit tests on WSIF code.
@@ -127,6 +128,7 @@
suite.addTest(new TestSuite(InputPartsTest.class));
suite.addTest(new TestSuite(OutputPartsTest.class));
suite.addTest(new TestSuite(WildcardTest.class));
+ suite.addTest(new TestSuite(ZipCodeAxisTest.class));
if (TestUtilities.areWeTesting("mime"))
suite.addTest(new TestSuite(MimeTest.class));