Migration to JBossWS
mailinator Jun 8, 2006 10:13 AMHi all,
I made a small client to get a currency conversion rate width this WS http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
This client worked well with org.jboss.axis classes (in JBOSS 4.0.3).
I need to migrate to JBOSS 4.0.4. But i'm too stupid to do it. Here is my code. Any idea please ?
import java.rmi.RemoteException; import javax.xml.namespace.QName; import javax.xml.rpc.Call; import javax.xml.rpc.ParameterMode; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import org.jboss.ws.Constants; import org.jboss.ws.utils.JavaUtils; public class Toto { private static final String SOAP_ACTION = "http://www.webserviceX.NET/ConversionRate"; private static final String TARGET_NAMESPACE = "http://www.webserviceX.NET/"; private static final QName SERVICE = new QName(TARGET_NAMESPACE, "CurrencyConvertor"); private static final String ENDPOINT = "http://www.webservicex.net/CurrencyConvertor.asmx"; public static void main(String[] args) { ServiceFactory factory; Service service; Call call; try { factory = ServiceFactory.newInstance(); service = factory.createService(SERVICE); call = service.createCall(); call.setOperationName(new QName(TARGET_NAMESPACE, "ConversionRate")); call.addParameter("FromCurrency", Constants.TYPE_LITERAL_STRING, ParameterMode.IN); call.addParameter("ToCurrency2", Constants.TYPE_LITERAL_STRING, ParameterMode.IN); call.setReturnType(Constants.TYPE_LITERAL_DOUBLE); call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE); call.setProperty(Call.SOAPACTION_URI_PROPERTY, SOAP_ACTION); call.setTargetEndpointAddress(ENDPOINT); Object resp = call.invoke(new Object[] { "EUR", "USD" }); if (resp instanceof RemoteException) { throw (RemoteException) resp; } else { try { System.out.println( ((Double) resp).doubleValue() ); } catch (Exception e) { System.out.println( ((Double) JavaUtils.getPrimitiveValue(resp)).doubleValue() ); } } } catch (Exception e) { e.printStackTrace(); } } }
log4j:WARN No appenders could be found for logger (org.jboss.ws.soap.MessageContextAssociation). log4j:WARN Please initialize the log4j system properly. java.rmi.RemoteException: Call invocation failed with code [Client] because of: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing); nested exception is: javax.xml.rpc.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:715) at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:398) at Toto.main(Toto.java:36) Caused by: javax.xml.rpc.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) at org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper.getSOAPFaultException(SOAPFaultExceptionHelper.java:100) at org.jboss.ws.binding.soap.SOAPBindingProvider.unbindResponseMessage(SOAPBindingProvider.java:505) at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:704) ... 2 more
Thx