当我到达调用我在Tomcat / Axis上运行的REALLY BASIC Web服务的行时,我收到以下错误。

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

我的QName有问题吗? - 我甚至找不到任何有用的信息。

我的客户代码如下:

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());
        }
    }
}

我的网络服务代码非常基本 - 只是一个简单的类,它返回带有一些连接文本的输入字符串:

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

    }
有帮助吗?

解决方案

如异常所示,您错误地调用了QName构造函数:

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

不正确。我认为你必须传递两个字符串,一个包含命名空间,一个包含localname。该文档通常包含有关如何使用该类的说明。

其他提示

你的QName可能是拼写错误吗?:

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

而不是:

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

您应该使用其中一种:

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

但     新QName(" http://testPackage.fc.com/ ,doBasicStuff") 是错误的,因为两个值都在同一个字符串“..,..”中。

此致

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

只需键入您的案例所必需的metod名称即可 <代码> call.setOperationName(QUOT; doBasicStuff&QUOT);

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top