参数未传递到 .net webservice

发布于 2024-10-21 04:20:54 字数 1074 浏览 4 评论 0原文

我在将参数传递给 .Net Web 服务时遇到问题。我使用 axis 和 java 作为客户端。当我运行 java 客户端并同时调试 Web 服务时,我能够调用 Web 服务,但是当我检查传递给 .net Web 服务的参数时,该值什么都没有。我应该怎么办?

这是我的代码:

try {
    String endpoint = "http://localhost/Test/Service.asmx?WSDL";
    Service  xxx = new Service();
    Call call = (Call) (xxx.createCall());

    sAcctNo = "test";

    call.setTargetEndpointAddress( new java.net.URL(sEndPoint) );
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY,new Boolean(true));
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY,"http://tempuri.org/GetName");
    call.setOperationName(new QName("GetName"));

    call.setProperty(javax.xml.rpc.Call.OPERATION_STYLE_PROPERTY,"document");

    call.addParameter( new QName("http://tempuri.org","str"),XMLType.XSD_STRING,ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);

    call.setEncodingStyle(null);

    ret = (String) call.invoke( new Object[]{ sAcctNo  } );
    out.println("You passed : '" + ret + "'");

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

I'm having a problem in passing my parameters to a .Net webservice. I'm using axis and java as a client. when I run my java client and debug my webservice at the same time I am able to invoke the webservice but when I check the parameters passed to the .net webservice the value is nothing. what should I do?

Here is my code:

try {
    String endpoint = "http://localhost/Test/Service.asmx?WSDL";
    Service  xxx = new Service();
    Call call = (Call) (xxx.createCall());

    sAcctNo = "test";

    call.setTargetEndpointAddress( new java.net.URL(sEndPoint) );
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY,new Boolean(true));
    call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY,"http://tempuri.org/GetName");
    call.setOperationName(new QName("GetName"));

    call.setProperty(javax.xml.rpc.Call.OPERATION_STYLE_PROPERTY,"document");

    call.addParameter( new QName("http://tempuri.org","str"),XMLType.XSD_STRING,ParameterMode.IN);
    call.setReturnType(XMLType.XSD_STRING);

    call.setEncodingStyle(null);

    ret = (String) call.invoke( new Object[]{ sAcctNo  } );
    out.println("You passed : '" + ret + "'");

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罗罗贝儿 2024-10-28 04:20:54

我认为这可能是操作名称的命名空间问题。

尝试替换:

call.setOperationName(new QName("GetName"));

call.setOperationName(new QName("http://tempuri.org", "GetName"));

命名空间是 QName 构造函数的第一个参数。它可能有助于调试来自工作 .NET 客户端的 SOAP 消息并与生成的 Java 客户端消息进行比较。

I think it might be a namespace issue with the operation name.

Try replacing:

call.setOperationName(new QName("GetName"));

with

call.setOperationName(new QName("http://tempuri.org", "GetName"));

Namespace is the first parameter of QName constructor. It might help to debug the SOAP message from a working .NET client and compare to the generated Java client message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文