Java @在提供soap的jetty中,WebParam始终为空

Java @在提供soap的jetty中,WebParam始终为空,java,web-services,soap,jetty,jax-ws,Java,Web Services,Soap,Jetty,Jax Ws,我有一个通过Jetty公开SOAP API的java应用程序。我可以成功访问WSDL并伪造请求,但发送的webparam始终为空。我不知道如何调试这个问题。 这里我有一些请求中涉及的函数片段。 如果您需要更多信息,我将进行编辑: @WebMethod( operationName = "findEvent" ) public ServiceEventDto findEvent( @WebParam(name = "eventId") Lon

我有一个通过Jetty公开SOAP API的java应用程序。我可以成功访问WSDL并伪造请求,但发送的webparam始终为空。我不知道如何调试这个问题。 这里我有一些请求中涉及的函数片段。 如果您需要更多信息,我将进行编辑:

@WebMethod(
        operationName = "findEvent"
    )
    public ServiceEventDto findEvent(
            @WebParam(name = "eventId") Long eventId) throws InstanceNotFoundException {
        Event event
                = EventServiceFactory.getService().findEvent(eventId);
        return EventToEventDtoConversor.toEventDto(event);
    }
请求如下:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eve="http://ws.udc.es/event">
<x:Header/>
<x:Body>
    <eve:findEvent>
        <eve:eventId>0</eve:eventId>
    </eve:findEvent>
</x:Body>

0


提前谢谢。

我认为问题在于您的SOAP输入使用了
eve
名称空间前缀作为
eventId
输入元素

试试这个:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eve="http://ws.udc.es/event">
<x:Header/>
<x:Body>
    <eve:findEvent>
        <eventId>0</eventId>
    </eve:findEvent>
</x:Body>
服务实施:

package org.example.sampleservice;

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;

@WebService(endpointInterface = "org.example.sampleservice.SampleService", targetNamespace="http://ws.udc.es/event")
public class SampleServiceImpl implements SampleService {

    @Resource
    private WebServiceContext ctx;

    @WebMethod(operationName = "findEvent")
    public ServiceEventDto findEvent(@WebParam(name = "eventId") Long eventId) throws InstanceNotFoundException {
        System.out.println("SampleServiceImpl: received eventId " + eventId);
        return new ServiceEventDto();
    }

}
当我将原始输入与
0
一起使用时,我观察到以下输出:

SampleServiceImpl:received eventId null

当我使用
0
时,我观察到预期的输出:

SampleServiceImpl:received eventId 0

但是,如果希望您接受
,您还可以调整
@webgram
以添加
targetNamespace
,如下所示:

 @WebParam(name = "eventId", targetNamespace="http://ws.udc.es/event") Long eventId

当我以这种方式更改我的服务提供者时,输出被反转,并且
不再是
null
我认为问题在于您的SOAP输入使用
eve
命名空间前缀作为
eventId
输入元素

试试这个:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eve="http://ws.udc.es/event">
<x:Header/>
<x:Body>
    <eve:findEvent>
        <eventId>0</eventId>
    </eve:findEvent>
</x:Body>
服务实施:

package org.example.sampleservice;

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;

@WebService(endpointInterface = "org.example.sampleservice.SampleService", targetNamespace="http://ws.udc.es/event")
public class SampleServiceImpl implements SampleService {

    @Resource
    private WebServiceContext ctx;

    @WebMethod(operationName = "findEvent")
    public ServiceEventDto findEvent(@WebParam(name = "eventId") Long eventId) throws InstanceNotFoundException {
        System.out.println("SampleServiceImpl: received eventId " + eventId);
        return new ServiceEventDto();
    }

}
当我将原始输入与
0
一起使用时,我观察到以下输出:

SampleServiceImpl:received eventId null

当我使用
0
时,我观察到预期的输出:

SampleServiceImpl:received eventId 0

但是,如果希望您接受
,您还可以调整
@webgram
以添加
targetNamespace
,如下所示:

 @WebParam(name = "eventId", targetNamespace="http://ws.udc.es/event") Long eventId

当我以这种方式更改我的服务提供商时,输出将被反转,
不再是
null

,因此代码有findInvite和inviteId,XML有findEvent和eventId@SlipperySeal对不起,我复制了错误的代码,现在我将修复它。因此代码有findInvite和inviteId,XML有findEvent和eventId@SlipperySeal抱歉,我复制了错误的代码,我现在将修复它。这应该被接受为解决方案。添加
targetNamespace
帮助我解决了类似的问题。这应该被接受为解决方案。添加
targetNamespace
帮助我解决了类似的问题。