Question

I am getting the following error when I get to the line that invokes a REALLY BASIC web service I have running on Tomcat/Axis.

Element or attribute do not match QName production: QName::=(NCName':')?NCName

Have I got something wrong with QName?- I can't even find any useful information about it.

My client code is below:

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

    public class TestClient {

    public static void main(String [] args)
    {
        try{
            String endpoint = "http://localhost:8080/TestWebService/services/DoesMagic";  

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

            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
            call.setOperationName( new QName("http://testPackage.fc.com/, doBasicStuff") );

            String ret = (String) call.invoke( new Object[] {"some kind of message"} );

            System.out.println(ret);

        }catch(Exception e){
            System.err.println(e.toString());
        }
    }
}

My web serivce code is really basic - just a simple class that returns your input string with a bit of concat text:

public String doBasicStuff(String message)
    {
        return "This is your message: " + message;

    }
Was it helpful?

Solution

As the exception says, you call the QName constructor incorrectly:

new QName("http://testPackage.fc.com/, doBasicStuff")

is incorrect. I think you have to pass two strings, one containing the namespace, one the localname. The documentation will typically contain a description on how to use that class.

OTHER TIPS

Could it be a typo in your QName?:

new QName("http://testPackage.fc.com/", "doBasicStuff")

instead of:

new QName("http://testPackage.fc.com/, doBasicStuff")

You should use one of these:

public QName(String localPart)     or
public QName(final String namespaceURI, final String localPart)

but new QName("http://testPackage.fc.com/, doBasicStuff") is wrong, since both values are in the same string ".., .."

Regards

new QName("soapenc:string", "doBasicStuff")

Just type the name of metod that have to on your case it would be call.setOperationName("doBasicStuff");

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top