2

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;

    }
4

5 回答 5

7

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.

于 2008-10-14T14:56:02.993 回答
6

Could it be a typo in your QName?:

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

instead of:

new QName("http://testPackage.fc.com/, doBasicStuff")
于 2008-10-14T14:54:36.320 回答
0

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

于 2010-04-13T18:26:25.660 回答
0

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

于 2011-12-03T15:11:35.910 回答
0

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

于 2012-12-15T00:07:13.200 回答