Thanks Balaji, Actually I need to do it without any tool. I've to use SOAP API. I think I can do it using Call(). Can u tell me what I need to specify in Call.setTargetObjectURI()? is it the Web service name or some other identifier? Ajay
Ajay Chawla
Greenhorn
Joined: Jan 14, 2004
Posts: 11
posted
0
Iam getting the following fault when i run my client : - faultcode :soap:Client faultString :Server did not recognize the value of HTTP Header SOAPAction: my code is : - Call call = new org.apache.soap.rpc.Call(); URL url = new URL("http://delgtel304:7070/WebService2/JavaService1.asmx"); call.setTargetObjectURI"http://delgtel304:7070/WebService2/JavaService1.asmx"); call.setMethodName("JavaTest"); call.setEncodingStyleURI(org.apache.soap.Constants.NS_URI_SOAP_ENC); Vector vParam = new Vector(); vParam.addElement(new org.apache.soap.rpc.Parameter"str",String.class,"Ajay",null)); call.setParams(vParam); org.apache.soap.rpc.Response resp = call.invoke(url, "");
if(resp.generatedFault()){ org.apache.soap.Fault fault = resp.getFault(); System.out.println("faultcode :"+fault.getFaultCode()); System.out.println("faultString :"+fault.getFaultString()); } else{ org.apache.soap.rpc.Parameter result = resp.getReturnValue(); System.out.println(result.getValue()); } any help is greatly appreciated. Thanks
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
5
posted
0
Apparently your code is not setting the SOAP-Action header. You can do it with
[ March 10, 2004: Message edited by: Lasse Koskela ]
Originally posted by Balaji Loganathan: Read the documentation on using the pretty-tiny tool WSDL2Java
How to get WSDL2Java to work though... Whenever I try I get an error
C:\work\Java\SOAP\zip>java -cp %AXISCP% org.apache.axis.wsdl.WSDL2Java ZipServic e.wsdl Exception in thread "main" java.lang.NoClassDefFoundError: javax.wsdl.Definition at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.class$(JavaGeneratorFactory.java:163) at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.addDefinitionGenerators(JavaGeneratorFactory.java:163) at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.addGenerators JavaGeneratorFactory.java:133) at org.apache.axis.wsdl.toJava.JavaGeneratorFactory.<init> JavaGeneratorFactory.java:120) at org.apache.axis.wsdl.toJava.Emitter.<init>(Emitter.java:120) at org.apache.axis.wsdl.WSDL2Java.createParser(WSDL2Java.java:172) at org.apache.axis.wsdl.gen.WSDL2.<init>(WSDL2.java:113) at org.apache.axis.wsdl.WSDL2Java.<init>(WSDL2Java.java:161) at org.apache.axis.wsdl.WSDL2Java.main(WSDL2Java.java:289)
added some linebreaks to keep it readable other than that the classpath is empty so no conflicting libraries. Using J2SDK 1.4.2-b28 (I know Axis has trouble with 1.4 JDKs, but I suppose there must be a workaround?)
42
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
5
posted
0
You need the wsdl4j.jar in your classpath as well (if I remember correctly, that's where the javax.wsdl package is defined).
Jeroen Wenting
Ranch Hand
Joined: Oct 12, 2000
Posts: 5093
posted
0
cheers. Sometimes you just don't see your own mistakes however long you stare at them
Ajay Chawla
Greenhorn
Joined: Jan 14, 2004
Posts: 11
posted
0
Hi All, Thanks for all those reply's. But my problem still remains but now in a different form. I modified the code as: - System.setProperty("javax.xml.soap.MessageFactory","weblogic.webservice.core.soap.MessageFactoryImpl"); System.setProperty( "javax.xml.rpc.ServiceFactory","weblogic.webservice.core.rpc.ServiceFactoryImpl"); ServiceFactory factory = ServiceFactory.newInstance(); String targetNamespace = "http://tempuri.org/"; QName serviceName = new QName(targetNamespace,"JavaService1"); QName portName = new QName(targetNamespace,"JavaService1Soap"); QName operationName = new QName("http://schemas.xmlsoap.org/soap/http","JavaTest"); URL wsdlLocation = new URL("http://delgtel304:7070/WebService2/JavaService1.asmx?WSDL"); Service service = factory.createService(wsdlLocation, serviceName); Call call = service.createCall(portName, operationName); call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY, new Boolean(true)); call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY, "MySoapAction"); String result = (String) call.invoke(new Object[] {"BEAS"}); System.out.println("\n"); System.out.println("This example shows how to create a dynamic client application that invokes a non-WebLogic Web service."); System.out.println("The webservice used was:http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"); System.out.println("The quote for BEAS is: "); System.out.println(result);
I get this on console :- WARNINIG: Unable to find a javaType for the xmlType:['http://tempuri.org/']:Java Test. Make sure that you have registered this xml type in the type mapping Using SOAPElement instead WARNINIG: Unable to find a javaType for the xmlType:['http://tempuri.org/']:Java TestResponse. Make sure that you have registered this xml type in the type mappi ng Using SOAPElement instead Exception in thread "main" javax.xml.rpc.JAXRPCException: failed to invoke opera tion. Error in the soap layer (jaxm); nested exception is: Message[ failed to se rialize xml:weblogic.xml.schema.binding.SerializationException: mapping lookup f ailure. class=interface javax.xml.soap.SOAPElement class context=TypedClassConte xt{schemaType=['http://tempuri.org/']:JavaTest}]StackTrace[ javax.xml.soap.SOAPException: failed to serialize xml:weblogic.xml.schema.bindi ng.SerializationException: mapping lookup failure. class=interface javax.xml.soa p.SOAPElement class context=TypedClassContext{schemaType=['http://tempuri.org/'] :JavaTest} at weblogic.webservice.core.DefaultPart.toXML(DefaultPart.java:266) at weblogic.webservice.core.DefaultMessage.toXML(DefaultMessage.java:456 ) at weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.jav a:407) at weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.jav a:363) at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:423) at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:292) at TestClient2.main(TestClient2.java:35) Caused by: weblogic.xml.schema.binding.SerializationException: mapping lookup fa ilure. class=interface javax.xml.soap.SOAPElement class context=TypedClassContex t{schemaType=['http://tempuri.org/']:JavaTest} at weblogic.xml.schema.binding.RuntimeUtils.lookup_serializer(RuntimeUti ls.java:144) at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti ls.java:180) at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti ls.java:167) at weblogic.webservice.core.DefaultPart.toXML(DefaultPart.java:258) ... 6 more ] at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:432) at weblogic.webservice.core.rpc.CallImpl.invoke(CallImpl.java:292) at TestClient2.main(TestClient2.java:35) Thanks Ajay
Vishwa Kumba
Ranch Hand
Joined: Aug 27, 2003
Posts: 1064
posted
0
Did anybody solve this problem?. I am getting a similar error in Weblogic 8.1, when trying to invoke a web service with JAX-RPC (dynamic wsdl method).
Niral Trivedi
Ranch Hand
Joined: Nov 26, 2001
Posts: 46
posted
0
Hi,
I am also having similar problem when trying to connect to a WS using Axis client.
Can somebody tell me what should be the value for ? I tried setting it to blank and some other value but I get this error regardless. What is the significance of this property?
Thanks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.