0

I'm trying to create client with apache-cxf.
I need to run following web service http://soapclient.com/xml/soapresponder.wsdl
What i'm trying to achieve is i will give two parameters to this service and return result/response.

Here is my code below:

JaxWsDynamicClientFactory dfc = JaxWsDynamicClientFactory.newInstance();
Client client = dfc.createClient("http://soapclient.com/xml/soapresponder.wsdl");

Object res[] = client.invoke("echo", "test echo");
System.out.println("Result: " + res[0]);

I'm getting lots of error such as:

Exception in thread "main" java.lang.RuntimeException: Fatal error compiling schema from WSDL at {http://soapclient.com/xml/soapresponder.wsdl}: Unexpected <schema> appears at line 9 column 5
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory$InnerErrorListener.fatalError(DynamicClientFactory.java:759)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:90)
    at com.sun.proxy.$Proxy22.fatalError(Unknown Source)
    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.fatalError(SchemaCompilerImpl.java:322)
    at com.sun.tools.xjc.util.ErrorReceiverFilter.fatalError(ErrorReceiverFilter.java:87)
    at com.sun.xml.xsom.impl.parser.ParserContext$2.fatalError(ParserContext.java:211)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.unexpectedX(NGCCRuntimeEx.java:506)
    at com.sun.xml.xsom.impl.parser.state.NGCCHandler.unexpectedEnterElement(NGCCHandler.java:194)
    at com.sun.xml.xsom.impl.parser.state.Schema.enterElement(Schema.java:443)
    at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.startElement(NGCCRuntime.java:258)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.util.SubtreeCutter.startElement(SubtreeCutter.java:108)
    at com.sun.tools.xjc.reader.ExtensionBindingChecker.startElement(ExtensionBindingChecker.java:150)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker.startElement(IncorrectNamespaceURIChecker.java:128)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.xmlschema.parser.CustomizationContextChecker.startElement(CustomizationContextChecker.java:193)
    at org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner$LocationResolver.startElement(DOMForestScanner.java:147)
    at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244)
    at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:92)
    at com.sun.tools.xjc.reader.internalizer.DOMForestScanner.scan(DOMForestScanner.java:100)
    at com.sun.tools.xjc.reader.internalizer.DOMForestParser.parse(DOMForestParser.java:104)
    at com.sun.tools.xjc.ModelLoader$XMLSchemaParser.parse(ModelLoader.java:269)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:347)
    at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:128)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:168)
    at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:157)
    at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:534)
    at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:90)
    at com.sun.proxy.$Proxy20.bind(Unknown Source)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:321)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:241)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:234)
    at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:189)
    at TestCAse.main(TestCAse.java:8)
Caused by: org.xml.sax.SAXParseExceptionpublicId: http://soapclient.com/xml/soapresponder.wsdl; systemId: http://soapclient.com/xml/soapresponder.wsdl; lineNumber: 9; columnNumber: 5; Unexpected <schema> appears at line 9 column 5
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.unexpectedX(NGCCRuntimeEx.java:499)
    ... 35 more

1 Answer 1

2

It's failing because the WSDL that's published at that address is invalid. The specific point of failure that CXF is complaining about is this:

<types>
    <schema xmlns="http://www.w3.org/1999/XMLSchema" targetNamespace="http://www.SoapClient.com/xml/SoapResponder.xsd"></schema>
</types>

Notice the unqualified use of the <schema> tag? That tag is provided within the http://www.w3.org/2001/XMLSchema namespace, qualified with the prefix xsd. What should be in the WSDL is:

<types>
    <xsd:schema xmlns="http://www.w3.org/1999/XMLSchema" targetNamespace="http://www.SoapClient.com/xml/SoapResponder.xsd"></xsd:schema>
</types>

Why it turned out incorrectly is beyond me; afterall, the namespace and the prefix are properly declared at the top in the wsdl:

 xmlns:xsd="http://www.w3.org/2001/XMLSchema".

To resolve, save a local copy of that wsdl, make an edit to correct the unqualified tag use, and then use the corrected local copy in your application

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer but now im getting this error -> Exception in thread "main" java.lang.IllegalStateException: no source files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.