I wonder if anybody has encountered this issue, and might know if i am
doing something wrong, or if this is a bug?
I am using WSDL2Java, which works ok with regular ADB bindings. I
want to use my own java value objects, however, and have been trying
out JiBX. My jibx bindings test out ok, and the WSDL2Java code
generation using jibx works somewhat, but it generates a
MessageReceiverInOut class that has a compilation problem where it
catches my custom exception and calls toOm(...).
also, none of the /resources files are getting generated, including
services.xml.
intel mac
Eclipse 3.2.0
java 1.5.0-06
jibx 1.1
----------------------------------------------------
Here are my schemas:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://nextgen.ubc/schema/Dictionary"
xmlns:dict="http://nextgen.ubc/schema/Dictionary">
<xsd:simpleType name="StudentNumber">
<xsd:restriction base="xsd:string">
<xsd:length value="8"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="LastName">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="GivenName">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Program">
<xsd:restriction base="xsd:string">
<xsd:minLength value="2"/>
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Campus">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="VAN"/>
<xsd:enumeration value="OKAN"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Street">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="City">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Province">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="BC"/>
<xsd:enumeration value="AB"/>
<xsd:enumeration value="SK"/>
<xsd:enumeration value="MB"/>
<xsd:enumeration value="ON"/>
<xsd:enumeration value="PQ"/>
<xsd:enumeration value="NB"/>
<xsd:enumeration value="NS"/>
<xsd:enumeration value="PE"/>
<xsd:enumeration value="NF"/>
<xsd:enumeration value="YT"/>
<xsd:enumeration value="NT"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="PostalCode">
<xsd:restriction base="xsd:string">
<xsd:pattern value="([A-Z]\d[A-Z]\d[A-Z]\d)"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ErrorMessage">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ErrorCode">
<xsd:restriction base="xsd:string">
<xsd:length value="4"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://nextgen.ubc/schema/StudentKey"
xmlns:key="http://nextgen.ubc/schema/StudentKey"
xmlns:dict="http://nextgen.ubc/schema/Dictionary">
<xsd:import namespace="http://nextgen.ubc/schema/Dictionary"
schemaLocation="Dictionary.xsd"/>
<xsd:element name="StudentNumber" type="dict:StudentNumber"/>
<xsd:element name="StudentKey">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="key:StudentNumber" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://nextgen.ubc/schema/Address"
xmlns:addr="http://nextgen.ubc/schema/Address"
xmlns:dict="http://nextgen.ubc/schema/Dictionary">
<xsd:import namespace="http://nextgen.ubc/schema/Dictionary"
schemaLocation="Dictionary.xsd"/>
<xsd:element name="StudentNumber" type="dict:StudentNumber"/>
<xsd:element name="Street" type="dict:Street"/>
<xsd:element name="City" type="dict:City"/>
<xsd:element name="Province" type="dict:Province"/>
<xsd:element name="PostalCode" type="dict:PostalCode"/>
<xsd:element name="Address">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="addr:StudentNumber" minOccurs="1"
maxOccurs="1"/>
<xsd:element ref="addr:Street" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="addr:City" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="addr:Province" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="addr:PostalCode" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://nextgen.ubc/schema/StandardError"
xmlns:err="http://nextgen.ubc/schema/StandardError"
xmlns:dict="http://nextgen.ubc/schema/Dictionary">
<xsd:import namespace="http://nextgen.ubc/schema/Dictionary"
schemaLocation="Dictionary.xsd"/>
<xsd:element name="ErrorMessage" type="dict:ErrorMessage"/>
<xsd:element name="ErrorCode" type="dict:ErrorCode"/>
<xsd:element name="StandardError">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="err:ErrorMessage" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="err:ErrorCode" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
----------------------------------
This is my wsdl file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="AddressRetrieval"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:key="http://nextgen.ubc/schema/StudentKey"
xmlns:addr="http://nextgen.ubc/schema/Address"
xmlns:err="http://nextgen.ubc/schema/StandardError"
xmlns:service="http://nextgen.ubc/wsdl/AddressRetrieval"
targetNamespace="http://nextgen.ubc/wsdl/AddressRetrieval">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://nextgen.ubc/schema/StudentKey"
schemaLocation="../schemas/StudentKey.xsd"/>
<xsd:import namespace="http://nextgen.ubc/schema/Address"
schemaLocation="../schemas/Address.xsd"/>
<xsd:import namespace="http://nextgen.ubc/schema/StandardError"
schemaLocation="../schemas/StandardError.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="AddressRequest">
<wsdl:part element="key:StudentKey" name="AddressRequest" />
</wsdl:message>
<wsdl:message name="AddressResponse">
<wsdl:part element="addr:Address" name="AddressResponse" />
</wsdl:message>
<wsdl:message name="StandardError">
<wsdl:part element="err:StandardError" name="StandardError" />
</wsdl:message>
<wsdl:portType name="AddressRetrieval">
<wsdl:operation name="getAddress">
<wsdl:input message="service:AddressRequest" />
<wsdl:output message="service:AddressResponse" />
<wsdl:fault message="service:StandardError" name="StandardError" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AddressRetrievalSOAPBinding"
type="service:AddressRetrieval">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getAddress">
<soap:operation
soapAction="http://nextgen.ubc/wsdl/operation/getAddress" />
<wsdl:input>
<soap:body parts="AddressRequest" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body parts="AddressResponse" use="literal" />
</wsdl:output>
<wsdl:fault name="StandardError" >
<soap:fault name="StandardError" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AddressRetrievalService">
<wsdl:port binding="service:AddressRetrievalSOAPBinding"
name="AddressRetrieval">
<soap:address
location="http://www4.students.ubc.ca:9180/axis2/services/AddressRetrievalService"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
---------------------------------------------
These are my dto classes:
package ubc.nextgen.dto;
public class StudentKey {
private String studentNumber = null;
private StudentKey() {} // required by jibx compiler
public StudentKey(String studentNumber) {
this.studentNumber = studentNumber;
}
public String getStudentNumber() {
return studentNumber;
}
}
package ubc.nextgen.dto;
public class Address {
private String studentNumber = null;
private String street = null;
private String city = null;
private String province = null;
private String postalCode = null;
private Address() {} // necessary for jibx binding compiler
public Address(String studentNumber, String street, String city,
String province, String postalCode) {
this.studentNumber = studentNumber;
this.street = street;
this.city = city;
this.province = province;
this.postalCode = postalCode;
}
public String getCity() {
return city;
}
public String getPostalCode() {
return postalCode;
}
public String getProvince() {
return province;
}
public String getStreet() {
return street;
}
public String getStudentNumber() {
return studentNumber;
}
}
package ubc.nextgen.dto;
public class StandardError {
private String errorCode = null;
private String errorMessage = null;
private StandardError() {}
public StandardError(String errorCode, String errorMessage) {
this.errorCode = errorCode;
this.errorMessage = errorMessage;
}
public String getErrorCode() {
return errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
}
----------------------------------------
This is my jibx binding file:
<binding>
<mapping name="Address" class="ubc.nextgen.dto.Address">
<namespace uri="http://nextgen.ubc/schema/Address"
default="elements"/>
<value name="StudentNumber" field="studentNumber"/>
<value name="Street" field="street"/>
<value name="City" field="city"/>
<value name="Province" field="province"/>
<value name="PostalCode" field="postalCode"/>
</mapping>
<mapping name="StudentKey" class="ubc.nextgen.dto.StudentKey">
<namespace uri="http://nextgen.ubc/schema/StudentKey"
default="elements"/>
<value name="StudentNumber" field="studentNumber"/>
</mapping>
<mapping name="StandardError" class="ubc.nextgen.dto.StandardError">
<namespace uri="http://nextgen.ubc/schema/StandardError"
default="elements"/>
<value name="ErrorCode" field="errorCode"/>
<value name="ErrorMessage" field="errorMessage"/>
</mapping>
</binding>
----------------------------------------
This is my Java2Wsdl command:
./WSDL2Java.sh -uri
Workspace/nextgen/server/xml/wsdl/AddressRetrieval.wsdl -s -ss -g -ssi
-sd -d jibx -p ubc.nextgen.service.address -o Workspace/nextgen/server
-Ebindingfile Workspace/nextgen/server/xml/binding/binding.xml
-----------------------------------------
And these are the generated service classes:
/**
* AddressRetrievalServiceMessageReceiverInOut.java This file was
* auto-generated from WSDL by the Apache Axis2 version: 1.0 May 04, 2006
* (09:21:04 IST)
*/
package ubc.nextgen.service.address;
/**
* AddressRetrievalServiceMessageReceiverInOut message receiver
*/
public class AddressRetrievalServiceMessageReceiverInOut
extends org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver {
//
private static javax.xml.namespace.QName[] qNameArray = { };
private static final org.jibx.runtime.IBindingFactory bindingFactory;
static {
org.jibx.runtime.IBindingFactory factory = null;
try {
factory =
org.jibx.runtime.BindingDirectory.getFactory(ubc.nextgen.dto.Address.class);
} catch (Exception e) {
/**
* intentionally empty - report error on usage attempt
*/
}
bindingFactory = factory;
}
public void invokeBusinessLogic(
org.apache.axis2.context.MessageContext msgContext,
org.apache.axis2.context.MessageContext newMsgContext)
throws org.apache.axis2.AxisFault {
try {
// get the implementation class for the Web Service
Object obj = getTheImplementationObject(msgContext);
//Inject the Message Context if it is asked for
org.apache.axis2.engine.DependencyManager.configureBusinessLogicProvider(obj,
msgContext.getOperationContext());
AddressRetrievalServiceSkeletonInterface skel =
(AddressRetrievalServiceSkeletonInterface) obj;
//Out Envelop
org.apache.axiom.soap.SOAPEnvelope envelope = null;
//Find the axisOperation that has been set by the Dispatch
phase.
org.apache.axis2.description.AxisOperation op =
msgContext.getOperationContext()
.getAxisOperation();
if (op == null) {
throw new org.apache.axis2.AxisFault(
"Operation is not located, if this is doclit style
the SOAP-ACTION should specified via the SOAP Action to use the
RawXMLProvider");
}
String methodName;
if ((op.getName() != null) &
((methodName = op.getName().getLocalPart()) !=
null)) {
if ("getAddress".equals(methodName)) {
ubc.nextgen.dto.Address param5 = null;
//doc style
param5 =
skel.getAddress((ubc.nextgen.dto.StudentKey) fromOM(
msgContext.getEnvelope().getBody()
.getFirstElement(),
ubc.nextgen.dto.StudentKey.class,
getEnvelopeNamespaces(msgContext.getEnvelope())));
envelope = toEnvelope(getSOAPFactory(msgContext),
param5,
false);
}
newMsgContext.setEnvelope(envelope);
}
} catch
(ubc.nextgen.service.address.AddressRetrievalServiceSkeleton.StandardErrorException
e) {
org.apache.axis2.AxisFault f = new org.apache.axis2.AxisFault(
"StandardErrorException");
f.setDetail(toOM(e.getFaultMessage(), false));
throw f;
}
catch (Exception e) {
throw org.apache.axis2.AxisFault.makeFault(e);
}
}
private org.apache.axiom.om.OMElement toOM(ubc.nextgen.dto.Address
param,
org.apache.axiom.soap.SOAPFactory factory, boolean
optimizeContent) {
if (param instanceof org.jibx.runtime.IMarshallable) {
if (bindingFactory == null) {
throw new RuntimeException(
"Could not find JiBX binding information for
ubc.nextgen.dto.Address, JiBX binding unusable");
}
org.jibx.runtime.IMarshallable marshallable =
(org.jibx.runtime.IMarshallable) param;
int index = marshallable.JiBX_getIndex();
org.apache.axis2.jibx.JiBXDataSource source = new
org.apache.axis2.jibx.JiBXDataSource(marshallable,
bindingFactory);
org.apache.axiom.om.OMNamespace namespace =
factory.createOMNamespace(bindingFactory.getElementNamespaces()[index],
null);
return factory.createOMElement(source,
bindingFactory.getElementNames()[index], namespace);
} else {
throw new RuntimeException(
"No JiBX <mapping> defined for class
ubc.nextgen.dto.Address");
}
}
private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
org.apache.axiom.soap.SOAPFactory factory,
ubc.nextgen.dto.Address param, boolean optimizeContent) {
org.apache.axiom.soap.SOAPEnvelope envelope =
factory.getDefaultEnvelope();
if (param != null) {
envelope.getBody().addChild(toOM(param, factory,
optimizeContent));
}
return envelope;
}
private org.apache.axiom.om.OMElement toOM(
org.apache.axiom.om.OMElement param,
org.apache.axiom.soap.SOAPFactory factory, boolean
optimizeContent) {
if (param instanceof org.jibx.runtime.IMarshallable) {
if (bindingFactory == null) {
throw new RuntimeException(
"Could not find JiBX binding information for
ubc.nextgen.dto.Address, JiBX binding unusable");
}
org.jibx.runtime.IMarshallable marshallable =
(org.jibx.runtime.IMarshallable) param;
int index = marshallable.JiBX_getIndex();
org.apache.axis2.jibx.JiBXDataSource source = new
org.apache.axis2.jibx.JiBXDataSource(marshallable,
bindingFactory);
org.apache.axiom.om.OMNamespace namespace =
factory.createOMNamespace(bindingFactory.getElementNamespaces()[index],
null);
return factory.createOMElement(source,
bindingFactory.getElementNames()[index], namespace);
} else {
throw new RuntimeException(
"No JiBX <mapping> defined for class
org.apache.axiom.om.OMElement");
}
}
private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
org.apache.axiom.soap.SOAPFactory factory,
org.apache.axiom.om.OMElement param, boolean optimizeContent) {
org.apache.axiom.soap.SOAPEnvelope envelope =
factory.getDefaultEnvelope();
if (param != null) {
envelope.getBody().addChild(toOM(param, factory,
optimizeContent));
}
return envelope;
}
private org.apache.axiom.om.OMElement toOM(
ubc.nextgen.dto.StudentKey param,
org.apache.axiom.soap.SOAPFactory factory, boolean
optimizeContent) {
if (param instanceof org.jibx.runtime.IMarshallable) {
if (bindingFactory == null) {
throw new RuntimeException(
"Could not find JiBX binding information for
ubc.nextgen.dto.Address, JiBX binding unusable");
}
org.jibx.runtime.IMarshallable marshallable =
(org.jibx.runtime.IMarshallable) param;
int index = marshallable.JiBX_getIndex();
org.apache.axis2.jibx.JiBXDataSource source = new
org.apache.axis2.jibx.JiBXDataSource(marshallable,
bindingFactory);
org.apache.axiom.om.OMNamespace namespace =
factory.createOMNamespace(bindingFactory.getElementNamespaces()[index],
null);
return factory.createOMElement(source,
bindingFactory.getElementNames()[index], namespace);
} else {
throw new RuntimeException(
"No JiBX <mapping> defined for class
ubc.nextgen.dto.StudentKey");
}
}
private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
org.apache.axiom.soap.SOAPFactory factory,
ubc.nextgen.dto.StudentKey param, boolean optimizeContent) {
org.apache.axiom.soap.SOAPEnvelope envelope =
factory.getDefaultEnvelope();
if (param != null) {
envelope.getBody().addChild(toOM(param, factory,
optimizeContent));
}
return envelope;
}
/**
* get the default envelope
*/
private org.apache.axiom.soap.SOAPEnvelope toEnvelope(
org.apache.axiom.soap.SOAPFactory factory) {
return factory.getDefaultEnvelope();
}
private java.lang.Object fromOM(org.apache.axiom.om.OMElement param,
java.lang.Class type, java.util.Map extraNamespaces) {
try {
if (bindingFactory == null) {
throw new RuntimeException(
"Could not find JiBX binding information for
com.sosnoski.seismic.jibxsoap.Query, JiBX binding unusable");
}
org.jibx.runtime.impl.UnmarshallingContext ctx =
(org.jibx.runtime.impl.UnmarshallingContext)
bindingFactory.createUnmarshallingContext();
org.jibx.runtime.IXMLReader reader = new
org.jibx.runtime.impl.StAXReaderWrapper(param.getXMLStreamReaderWithoutCaching(),
"SOAP-message", true);
ctx.setDocument(reader);
return ctx.unmarshalElement(type);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* A utility method that copies the namepaces from the SOAPEnvelope
*/
private java.util.Map getEnvelopeNamespaces(
org.apache.axiom.soap.SOAPEnvelope env) {
java.util.Map returnMap = new java.util.HashMap();
java.util.Iterator namespaceIterator =
env.getAllDeclaredNamespaces();
while (namespaceIterator.hasNext()) {
org.apache.axiom.om.OMNamespace ns =
(org.apache.axiom.om.OMNamespace) namespaceIterator.next();
returnMap.put(ns.getPrefix(), ns.getName());
}
return returnMap;
}
} //end of class
/**
* AddressRetrievalServiceSkeleton.java This file was auto-generated
from WSDL
* by the Apache Axis2 version: 1.0 May 04, 2006 (09:21:04 IST)
*/
package ubc.nextgen.service.address;
/**
* AddressRetrievalServiceSkeleton java skeleton for the axisService
*/
public class AddressRetrievalServiceSkeleton
implements AddressRetrievalServiceSkeletonInterface {
/**
* Auto generated method signature
*
* @param param2
*/
public ubc.nextgen.dto.Address
getAddress(ubc.nextgen.dto.StudentKey param2)
throws
ubc.nextgen.service.address.AddressRetrievalServiceSkeleton.StandardErrorException
{
//Todo fill this with the necessary business logic
throw new java.lang.UnsupportedOperationException();
}
public static class StandardErrorException extends
java.rmi.RemoteException {
private org.apache.axiom.om.OMElement faultMessage;
public void setFaultMessage(org.apache.axiom.om.OMElement msg) {
faultMessage = msg;
}
public org.apache.axiom.om.OMElement getFaultMessage() {
return faultMessage;
}
}
}
/**
* AddressRetrievalServiceSkeletonInterface.java This file was
auto-generated
* from WSDL by the Apache Axis2 version: 1.0 May 04, 2006 (09:21:04 IST)
*/
package ubc.nextgen.service.address;
/**
* AddressRetrievalServiceSkeletonInterface java skeleton interface for the
* axisService
*/
public interface AddressRetrievalServiceSkeletonInterface {
/**
* Auto generated method signature
*
* @param param0
*/
public ubc.nextgen.dto.Address
getAddress(ubc.nextgen.dto.StudentKey param0)
throws
ubc.nextgen.service.address.AddressRetrievalServiceSkeleton.StandardErrorException;
}