aspose file tools*
The moose likes Web Services and the fly likes Currency Web  Service almost there Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Currency Web  Service almost there" Watch "Currency Web  Service almost there" New topic
Author

Currency Web Service almost there

Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Hi,
i created all the necessary stubs using apache axis for the webservice. i wrote a client, the code is listed below. The WSDL for the web service can be found at http://www.webservicex.net/CurrencyConvertor.asmx?WSDL.
i got the soap address and registered the QName. Could you please let me know where i am going wrong

Here is my code

public void startCCConvert(){
CurrencyConvertorLocator cclocator =new CurrencyConvertorLocator();
String ccsoapAddress = cclocator.getCurrencyConvertorSoapAddress();
System.out.println("SOAP ADDRESS LOCATION : " + ccsoapAddress );
try{
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL (ccsoapAddress));
call.setOperationName("http://www.webserviceX.NET/ConversionRate");
QName ConversionRate = new QName ("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", "Currency");
NET.webserviceX.www.Currency FromCurrency = NET.webserviceX.www.Currency.USD;
NET.webserviceX.www.Currency ToCurrency = NET.webserviceX.www.Currency.INR;


call.addParameter("FromCurrency",ConversionRate,ParameterMode.IN);
call.addParameter("ToCurrency",ConversionRate,ParameterMode.IN);
call.setReturnType(XMLType.XSD_DOUBLE);
Double ret = (Double) call.invoke(new Object [] {FromCurrency,ToCurrency});
}catch (MalformedURLException e ){
e.printStackTrace();
}catch (RemoteException e){
e.printStackTrace();
}catch (ServiceException e){
e.printStackTrace();
}
}

Here is my stack trace
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: 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)
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: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.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.test.wsclient.CCClient.startCCConvert(CCClient.java:54)
at com.test.wsclient.CCClient.main(CCClient.java:26)

{http://xml.apache.org/axis/}hostname:Rnizamuddin-745

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.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.test.wsclient.CCClient.startCCConvert(CCClient.java:54)
at com.test.wsclient.CCClient.main(CCClient.java:26)
Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Hello any body has some idea.

Thanks
Rashid
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
Given this error:


My first step would be to use TCPMON to capture the complete SOAP request with headers to see what is actually being written for SOAPaction.

Bill
Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
Thanks William

i cant intercept with the tcpmon utility coz the webservice which i am using is not located on my local machine. its written in .net and hosted remotely. i have some webservice installed on my local tomcat apache axis directoy and all my webservice client hit port 8081 and the tcpmon redirects them to localhost@ 8080. Anyway i was able to call this webservice from .net and jdeveloper since they do most of the dirty work of implementation. i just need a way on how to pass my custom object usign beanserializer. if you have any tutorial on that please let me know
here is my code
try{




Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL ("http://www.webservicex.net/CurrencyConvertor.asmx"));
//call.setOperationName("conversionRate");
call.setOperationName(new QName("http://www.webservicex.net/CurrencyConvertor.asmx", "conversionRate"));
QName cRate = new QName("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", "ConversionRate");
//QName ConversionRateResponse = new QName("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", "double");
ConversionRate convRate = new ConversionRate();
convRate.setToCurrency(dotnet.Currency.INR);
convRate.setFromCurrency(dotnet.Currency.USD);


call.addParameter("convRate",cRate,ParameterMode.IN);
call.setReturnType(XMLType.XSD_DOUBLE);
Object ret = call.invoke(new Object [] {convRate});
}catch (MalformedURLException e ){
e.printStackTrace();
}catch (RemoteException e){
e.printStackTrace();
}catch (ServiceException e){
e.printStackTrace();
}
Thanks
Rashid
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
i cant intercept with the tcpmon utility coz the webservice which i am using is not located on my local machine. its written in .net and hosted remotely. i have some webservice installed on my local tomcat apache axis directoy and all my webservice client hit port 8081 and the tcpmon redirects them to localhost@ 8080.[/QB]


tcpmon is perfectly capable of redirecting to a remote host - that's what the "Target Hostname" field is for.


Ping & DNS - my free Android networking tools app
 
jQuery in Action, 2nd edition
 
subject: Currency Web Service almost there