This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am trying to invoke a web-service that returns a String to my Java Client.. Here's the code snippet.. String endpoint = "http://workstation-12:7001/axis/wsdl/DbWebService.wsdl"; Service service = new Service(); Call call = (Call) service.createCall(); call.setOperationStyle(org.apache.axis.enum.Style.WRAPPED); call.setOperationUse(org.apache.axis.enum.Use.LITERAL); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName("http://dbwebservice","getStockPrice")); call.addParameter(new javax.xml.namespace.QName("http://dbwebservice","ticker"), org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(org.apache.axis.Constants.XSD_STRING); String ret = (String) call.invoke(new Object[]{ticker}); out.println(ret); Here's the genarated wsdl which invokes the method OKAY when tried from other clients like .NET <?xml version="1.0" encoding="UTF-8" ?> - <wsdl:definitions targetNamespace="http://workstation-12:7001/axis/services/DbWebService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://workstation-12:7001/axis/services/DbWebService" xmlns:intf="http://workstation-12:7001/axis/services/DbWebService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <wsdl:message name="getStockPriceRequest"> <wsdl:part name="in0" type="xsd:string" /> </wsdl:message> - <wsdl:message name="getStockPriceResponse"> <wsdl:part name="getStockPriceReturn" type="xsd:string" /> </wsdl:message> - <wsdl:portType name="TestDbWebService"> - <wsdlperation name="getStockPrice" parameterOrder="in0"> <wsdl:input message="intf:getStockPriceRequest" name="getStockPriceRequest" /> <wsdlutput message="intf:getStockPriceResponse" name="getStockPriceResponse" /> </wsdlperation> </wsdl:portType> - <wsdl:binding name="DbWebServiceSoapBinding" type="intf:TestDbWebService"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdlperation name="getStockPrice"> <wsdlsoapperation soapAction="" /> - <wsdl:input name="getStockPriceRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://dbwebservice" use="encoded" /> </wsdl:input> - <wsdlutput name="getStockPriceResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://workstation-12:7001/axis/services/DbWebService" use="encoded" /> </wsdlutput> </wsdlperation> </wsdl:binding> - <wsdl:service name="TestDbWebServiceService"> - <wsdl:port binding="intfbWebServiceSoapBinding" name="DbWebService"> <wsdlsoap:address location="http://workstation-12:7001/axis/services/DbWebService" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
But with the above java client I'm getting the following error stack.... AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: org.xml.sax.SAXException: Bad envelope tag: definitions faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXException: Bad envelope tag: definitions at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:109) Where I am going wrong here... I think in my client this exception is generated when I am setting the Operation Names and Params -- call.setOperationName(new QName("http://dbwebservice","getStockPrice")); call.addParameter(new javax.xml.namespace.QName("http://dbwebservice","ticker"), any ideas?? Sam
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
Originally posted by Sam Bom: I am trying to invoke a web-service that returns a String to my Java Client.. Here's the code snippet.. String endpoint = "http://workstation-12:7001/axis/wsdl/DbWebService.wsdl"; Service service = new Service(); Call call = (Call) service.createCall(); call.setOperationStyle(org.apache.axis.enum.Style.WRAPPED); call.setOperationUse(org.apache.axis.enum.Use.LITERAL); call.setTargetEndpointAddress(new java.net.URL(endpoint)); Sam
Isn't that your endpoint shd point to "http://workstation-12:7001/axis/services/DbWebService"
I�m getting a �Bad Envelope Tag: Definitions� error when I try calling the webservice from my client. Any thoughts/suggestions on this is highly appreciated.
Thanks, Cyril
Error Stack Trace
stackTrace: org.xml.sax.SAXException: Bad envelope tag: definitions at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:107) at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:906) at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1376) at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284) at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:949) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at javax.xml.parsers.SAXParser.parse(Unknown Source) at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546) at org.apache.axis.Message.getSOAPEnvelope(Message.java:377) at org.apache.axis.client.Call.invokeEngine(Call.java:2132) at org.apache.axis.client.Call.invoke(Call.java:2102) at org.apache.axis.client.Call.invoke(Call.java:1851) at org.apache.axis.client.Call.invoke(Call.java:1777) at org.apache.axis.client.Call.invoke(Call.java:1315) at com.wamu.p2p.rms.URSA_XML_Receiver.URSA2_P2P_ReceiverSoapBindingStub.opCreate(URSA2_P2P_ReceiverSoapBindingStub.java:210) at com.wamu.p2p.rms.ConnectReceiverTester.main(ConnectReceiverTester.java:147)