I'm attempting to consume a WS and am having no luck Marshalling or UnMarshalling through JiBX. I was hoping some assistance from the board will prevent me from checking into the Loony Bin...
I'm currently using JDK 1.5, and JiBX 1.1.5, and used xsd2jibx xsd2jibx-beta0.2b to generate my Client stubs & binding.xml
Any examples using JiBX would be much appreciated, as I could not find any on the web.
The Exception I'm getting:
My ApplicationContext is as follows:HTML Code:Unable to access binding information for class net.webservicex.GetWeatherByZipCode Make sure the binding has been compiled;
My Client Source is as follow:HTML Code:<bean id="webServiceClient" class="com.company.WebServiceClient"> <property name="defaultUri" value="http://www.webservicex.net/WeatherForecast.asmx"/> <property name="marshaller" ref="marshaller" /> <property name="unmarshaller" ref="unmarshaller" /> </bean> <bean id="marshaller" class="org.springframework.oxm.jibx.JibxMarshaller" > <property name="targetClass"><value>net.webservicex.GetWeatherByZipCode</value></property> </bean> <bean id="unmarshaller" class="org.springframework.oxm.jibx.JibxMarshaller" > <property name="targetClass"><value>net.webservicex.GetWeatherByZipCodeResponse</value></property> </bean>
The WSDL can be found at: http://localhost:8080/axis2/services...ngService?wsdlHTML Code:public class WebServiceClient extends WebServiceGatewaySupport{ public void customSendAndReceive() { GetWeatherByZipCode gvr = new GetWeatherByZipCode(); gvr.setZipCode("19026"); GetWeatherByZipCodeResponse response = (GetWeatherByZipCodeResponse) getWebServiceTemplate().marshalSendAndReceive(gvr, new WebServiceMessageCallback(){ public void doInMessage(WebServiceMessage message) { ((SoapMessage)message).setSoapAction("http://www.webservicex.net/GetWeatherByZipCode"); } public void doWithMessage(WebServiceMessage arg0) throws IOException, TransformerException { // TODO Auto-generated method stub } }); } public static void main(String[] args) throws IOException { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml", WebServiceClient.class); WebServiceClient ws = (WebServiceClient) applicationContext.getBean("webServiceClient"); ws.customSendAndReceive();
The Schema is as follow:
The JiBX Binding is as follow:HTML Code:<?xml version="1.0" encoding="UTF-8"?> <s:schema elementFormDefault="qualified" targetNamespace="http://www.webservicex.net" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.webservicex.net"> <s:element name="GetWeatherByZipCode"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string"/> </s:sequence> </s:complexType> </s:element> <s:element name="GetWeatherByZipCodeResponse"> <s:complexType> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="GetWeatherByZipCodeResult" type="tns:WeatherForecasts"/> </s:sequence> </s:complexType> </s:element> <s:complexType name="WeatherForecasts"> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="Latitude" type="s:float"/> <s:element minOccurs="1" maxOccurs="1" name="Longitude" type="s:float"/> <s:element minOccurs="1" maxOccurs="1" name="AllocationFactor" type="s:float"/> <s:element minOccurs="0" maxOccurs="1" name="FipsCode" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="PlaceName" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Status" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Details" type="tns:ArrayOfWeatherData"/> </s:sequence> </s:complexType> <s:complexType name="ArrayOfWeatherData"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="WeatherData" type="tns:WeatherData"/> </s:sequence> </s:complexType> <s:complexType name="WeatherData"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="Day" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="WeatherImage" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureF" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="MinTemperatureF" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="MaxTemperatureC" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="MinTemperatureC" type="s:string"/> </s:sequence> </s:complexType> </s:schema>
HTML Code:<?xml version="1.0" encoding="UTF-8"?> <binding> <mapping name="GetWeatherByZipCode" class="net.webservicex.GetWeatherByZipCode"> <namespace uri="http://www.webservicex.net" default="elements"/> <value name="ZipCode" field="zipCode" usage="optional"/> </mapping> <mapping name="GetWeatherByZipCodeResponse" class="net.webservicex.GetWeatherByZipCodeResponse"> <namespace uri="http://www.webservicex.net" default="elements"/> <structure field="getWeatherByZipCodeResult" usage="required" map-as="net.webservicex.WeatherForecasts"/> </mapping> <mapping name="GetWeatherByZipCodeResult" class="net.webservicex.WeatherForecasts"> <namespace uri="http://www.webservicex.net" default="elements"/> <value name="Latitude" field="latitude" usage="required"/> <value name="Longitude" field="longitude" usage="required"/> <value name="AllocationFactor" field="allocationFactor" usage="required"/> <value name="FipsCode" field="fipsCode" usage="optional"/> <value name="PlaceName" field="placeName" usage="optional"/> <value name="StateCode" field="stateCode" usage="optional"/> <value name="Status" field="status" usage="optional"/> <structure field="details" usage="optional" map-as="net.webservicex.ArrayOfWeatherData"/> </mapping> <mapping name="Details" class="net.webservicex.ArrayOfWeatherData"> <namespace uri="http://www.webservicex.net" default="elements"/> <collection field="weatherDataList"> <structure map-as="net.webservicex.WeatherData"/> </collection> </mapping> <mapping name="WeatherData" class="net.webservicex.WeatherData"> <namespace uri="http://www.webservicex.net" default="elements"/> <value name="Day" field="day" usage="optional"/> <value name="WeatherImage" field="weatherImage" usage="optional"/> <value name="MaxTemperatureF" field="maxTemperatureF" usage="optional"/> <value name="MinTemperatureF" field="minTemperatureF" usage="optional"/> <value name="MaxTemperatureC" field="maxTemperatureC" usage="optional"/> <value name="MinTemperatureC" field="minTemperatureC" usage="optional"/> </mapping> </binding>
Thanks in advance!!!
-Marcelo



Reply With Quote