简体   繁体   English

Java错误消耗WCF服务

[英]Java error Consuming WCF Service

I'm started to develop a Web Service with WCF and created a WCF Service poject. 我开始使用WCF开发Web服务,并创建了WCF服务项目。 I let all as it was and imported the service in netbeans as JAX WS service. 我照原样将服务导入到netbeans中作为JAX WS服务。 All seems to be fine. 一切似乎都很好。

Service1 test= new Service1();
CompositeType ct=new CompositeType();
ct.setBoolValue(Boolean.TRUE);
ObjectFactory factory=new ObjectFactory();
ct.setStringValue(factory.createString("StringValue"));    
CompositeType result= test.getBasicHttpBindingIService1().getDataUsingDataContract(ct);

I can send the request. 我可以发送请求。 I can break in Visual studio and see the CompositeType object. 我可以在Visual Studio中休息一下,然后查看CompositeType对象。 But the object is not as it should be: 但是对象不是应该的:

  • The bool value is set as expected to true . 布尔值设置为true
  • The string value is still null . 字符串值仍然为null
  • When i manipulate the string value in the WCF Service and give the change object back the string is set correct and i can read it in java. 当我在WCF服务中操纵字符串值并将更改对象还给我时,该字符串设置正确,并且可以在Java中读取它。

Why can't i post the CompositeType to java but can consume it? 为什么我不能将CompositeType发布到Java,但可以使用它?

It's hard to tell from just the detail you've provided. 仅凭您提供的细节很难分辨。

Here is what I suggest: 这是我的建议:

Generally, once you do this, you should plenty of more info on what's going funky at the service side and can diagnose the issue pretty quickly. 通常,一旦执行此操作,您就应该在服务端获取更多有关时髦问题的信息,并且可以很快地诊断出问题。 Try it, and please report back! 试试看,请回报! :) :)

I also lost 2 hours in this! 我在此也损失了2个小时!

The problem is in java code :) 问题出在Java代码中:)

Instead of this 代替这个

ct.setStringValue(factory.createString("StringValue"));  

use this 用这个

ct.setStringValue(factory.createCompositeTypeStringValue("StringValue"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM