data unmarshalling error
parallax Aug 10, 2005 4:19 AMHi,
I have written a WS client as suggested in the wiki. When i run the client i get the following error. It looks like the parser is trying to validate jaxrpc-mapping.xml and complains about validation failures. The jaxrpc-mapping.xml is auto generated from wscompile and can't be wrong. Any help would he highly appreciated. The client code can be found below:
javax.xml.rpc.ServiceException: org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[2,-1]
at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:167)
at com.drkw.ws.client.CreditFocusClient.getLoanMapping(CreditFocusClient.java:40)
2005-08-10 09:11:07,579 ERROR org.jboss.webservice.client.ServiceFactoryImpl[main] - Element type "java-wsdl-mapping" is not declared. @ *unknown*[2,-1]
at com.drkw.ws.client.CreditFocusClient.main(CreditFocusClient.java:53)
org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[2,-1]
at org.jboss.xml.binding.Unmarshaller$MetaDataErrorHandler.error(Unmarshaller.java:170)
at org.apache.crimson.parser.Parser2.error(Parser2.java:3359)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1502)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:153)
at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:140)
at org.jboss.webservice.metadata.jaxrpcmapping.JavaWsdlMappingFactory.parse(JavaWsdlMappingFactory.java:62)
at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:158)
at com.drkw.ws.client.CreditFocusClient.getLoanMapping(CreditFocusClient.java:40)
at com.drkw.ws.client.CreditFocusClient.main(CreditFocusClient.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: org.xml.sax.SAXException: Element type "java-wsdl-mapping" is not declared. @ *unknown*[2,-1]
at org.jboss.xml.binding.Unmarshaller$MetaDataErrorHandler.error(Unmarshaller.java:170)
at org.apache.crimson.parser.Parser2.error(Parser2.java:3359)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1502)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:153)
at org.jboss.xml.binding.Unmarshaller.unmarshal(Unmarshaller.java:140)
at org.jboss.webservice.metadata.jaxrpcmapping.JavaWsdlMappingFactory.parse(JavaWsdlMappingFactory.java:62)
at org.jboss.webservice.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:158)
... 7 more
******************Client**********
package com.drkw.ws.client;
/**
* Created by IntelliJ IDEA.
* User: jaitlyr
* Date: 01-Aug-2005
* Time: 10:57:22
* To change this template use File | Settings | File Templates.
*/
import org.jboss.webservice.client.ServiceFactoryImpl;
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import java.net.URL;
import java.util.Date;
import java.text.SimpleDateFormat;
public class CreditFocusClient {
private static final String WSDL_LOCATION = "http://localhost:8080/marketData/MarketDataWebTier?wsdl";
private static String NAMESPACE = "http://www.drkw.com/creditFocus/MarketDataWebTier";
private static final QName SERVICE_NAME = new QName(NAMESPACE, "MarketDataWebTier");
private final SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy");
public String getLoan(String loanNumber, Date date) throws Exception {
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service service = serviceFactory.createService(new URL(WSDL_LOCATION), SERVICE_NAME);
Call call = (Call) service.createCall(new QName(NAMESPACE, "MarketDataWebTierServicePort"), "getLoan");
return (String) call.invoke(new Object[]{loanNumber, date});
}
public Object getLoanMapping(String loanNumber) throws Exception {
ServiceFactoryImpl serviceFactory = (ServiceFactoryImpl)ServiceFactory.newInstance();
URL wsdlURL = new URL("http://localhost:8080/marketData/MarketDataWebTier?wsdl");
//URL wsdlURL = getClass().getClassLoader().getResource("META-INF/wsdl/MarketDataWebTier.wsdl");
URL jaxrpcURL = getClass().getClassLoader().getResource("MarketDataWebTier-mapping.xml");
URL ws4eeURL = getClass().getClassLoader().getResource("ws4ee-deployment.xml");
Service service = serviceFactory.createService(wsdlURL, jaxrpcURL, ws4eeURL, SERVICE_NAME, null);
Call call = (Call) service.createCall(new QName(NAMESPACE, "MarketDataWebTierServicePort"), "getLoanMapping");
return call.invoke(new Object[]{loanNumber});
// URL resource = getClass().getClassLoader().getResource("meta-inf/ws4ee-deployment.xml");
}
public static void main(String[] args)
throws Exception {
CreditFocusClient creditFocusClient = new CreditFocusClient();
String loan = creditFocusClient.getLoan("1002101", new Date());
System.out.println("LoanID: " + loan);
Object mapping = creditFocusClient.getLoanMapping("1002101");
System.out.println("Mapping " + mapping);
// String urlstr = "http://localhost:8080/marketData/MarketDataWebTier?wsdl";
// String namespace = "http://www.drkw.com/creditFocus/MarketDataWebTier";
// System.out.println("Contacting webservice at " + urlstr);
// URL url = new URL(urlstr);
// QName qname = new QName("http://www.drkw.com/creditFocus/MarketDataWebTier", "MarketDataWebTier");
//
// ServiceFactory factory = ServiceFactory.newInstance();
// Service service = factory.createService(url, qname);
//
// MarketDataWebTierService hello = (MarketDataWebTierService) service.getPort(MarketDataWebTierService.class);
// System.out.println("output:" + hello.getLoan("1002101", new Date()));
}
}