views:

3916

answers:

4

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;

    }
+3  A: 

Could it be a typo in your QName?:

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

instead of:

new QName("http://testPackage.fc.com/, doBasicStuff")
Rich Kroll
+3  A: 

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.

Martin Probst
If there was an idiot badge I think I should get it!
Vidar
A: 

(404)Not Found - error is thrown

A: 

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

German