web Service请求是报There must be a method name element错误

本文记录了一个关于WebService客户端遇到的问题及解决过程。问题表现为程序抛出XFireRuntimeException异常,提示无法调用服务。经过排查发现,请求URL中带有?wsdl导致异常,移除后问题解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天写了个测试web Service客户端的程序报如下错误,查了半天的。原来是请求的地址后面带了"?wsdl",最后去掉了,一切正常
Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: There must be a method name element.
org.codehaus.xfire.fault.XFireFault: There must be a method name element.
at org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:32)
at org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:406)
at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
at org.codehaus.xfire.client.Client.invoke(Client.java:336)
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy0.example(Unknown Source)
at clica.Test.main(Test.java:23)
### Java List BigInteger Field Sum Calculation Example In scenarios where one needs to calculate the sum of `BigInteger` fields within a `List`, specific methods and approaches must be adopted due to the nature of `BigInteger`. Unlike primitive types or simple wrapper classes like `Integer`, operations involving `BigInteger` require explicit handling. To perform summation over a list containing `BigInteger` elements, an iterative approach can be used. Here is how this process unfolds: #### Iterative Approach Using Stream API The introduction of Streams in Java 8 has simplified many collection-based operations including aggregation tasks such as calculating sums. The following code snippet demonstrates using streams with reduction (`reduce`) method specifically tailored for `BigInteger`. ```java import java.math.BigInteger; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<BigInteger> numbers = Arrays.asList( new BigInteger("123"), new BigInteger("4567"), new BigInteger("890") ); // Calculate sum using stream reduce operation BigInteger totalSum = numbers.stream() .reduce(BigInteger.ZERO, (a, b) -> a.add(b)); System.out.println("Total Sum: " + totalSum); } } ``` Alternatively, when dealing with objects having `BigInteger` properties inside lists, mapping those properties before performing any arithmetic becomes necessary. Consider a scenario wherein each element contains multiple attributes among which only one attribute holds numeric value represented by `BigInteger`. For demonstration purposes, assume there exists a custom class named `Item` holding various data points along with its constructor and getter/setter pairs defined accordingly. ```java class Item { private String name; private BigInteger amount; public Item(String name, BigInteger amount) { this.name = name; this.amount = amount; } public BigInteger getAmount() { return amount; } } ``` Given above definition, here's how to compute aggregate values across all items stored within a list based upon their respective amounts expressed via `BigInteger`. ```java import java.math.BigInteger; import java.util.ArrayList; import java.util.List; // ... List<Item> itemList = new ArrayList<>(Arrays.asList( new Item("itemA", new BigInteger("1")), new Item("itemB", new BigInteger("2")), new Item("itemC", new BigInteger("3")) )); BigInteger itemSum = itemList.stream() .map(Item::getAmount) .reduce(BigInteger.ZERO, BigInteger::add); System.out.println("Items Total Amount: " + itemSum); ``` Both examples illustrate effective ways to handle accumulation processes while ensuring precision through utilization of `BigInteger`'s inherent capabilities[^1].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值