标签: jax-ws

如何在 Spring 中配置 jax-ws 处理程序?

我根据 jax-ws API 集成 jax-ws 与 Spring ,但我在我的 webservice 项目中遇到异常,这里是 API 站点:http://jax-ws-commons.java.net/spring/,我有相同的配置 xml在我的项目中,但我得到一个例外如下:

    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'handlers'                   is not allowed to appear in element 'ws:service'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
Run Code Online (Sandbox Code Playgroud)

谁能给我解决方案?

web-services jax-ws

2
推荐指数
1
解决办法
2185
查看次数

在 Java Web 服务中生成的客户端工件

我曾参与过相当多使用 JAX-WS 实现的 Web 服务项目,例如 Axis。工件是使用 IDE 生成的,并且它可以工作。但是,我想知道生成的客户端工件以及它们的作用。如果您能提供任何明确的指南或来源,将会很有帮助。

我知道如何生成工件。但找不到任何描述生成的客户端工件及其用途的来源。

java soa soap web-services jax-ws

2
推荐指数
1
解决办法
1765
查看次数

如何将不继承 BindingProvider 的对象显式转换为 BindingProvider 对象?

我有一个 Web 服务,我在其中使用客户端 API 中的服务接口对象操作 SOAP 标头。

我需要将端口对象类型转换为BindingProvider对象。但是我的端口对象没有直接继承那个类。那么JVM怎么可能不抱怨呢?

它也有效。ClassCastException 没有运行时错误

代码片段:

    public SearchDocument getSearchDocumentService(String wsdlUri, AuthBean auth){
    SearchDocument_Service serv = null;
    serv = SearchDocument_Service.getServiceInstance(wsdlUri);
    SearchDocument searchDoc = serv.getSearchDocument();

    populateAuthAndHandlerInfo((BindingProvider)searchDoc, auth);//how is it that jvm doesn't complain here
    return searchDoc;
    }

    private void populateAuthAndHandlerInfo(BindingProvider port, AuthBean auth) {
    Binding binding = port.getBinding();
              List<Handler> handlerList = binding.getHandlerChain();
              handlerList.add(new EDMSSoapAuthHandler());
              binding.setHandlerChain(handlerList);
        Map<String, Object> context = port.getRequestContext();
        context.put("clientAuthInfo", auth);
        }
Run Code Online (Sandbox Code Playgroud)

搜索文档.java:

    @WebService(name = "SearchDocument", targetNamespace = "http://services.abc.com/Technology/SearchDocument/service/v1")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
    ObjectFactory.class …
Run Code Online (Sandbox Code Playgroud)

java web-services jax-ws soap-client jakarta-ee

2
推荐指数
1
解决办法
1464
查看次数

如何向 SOAP URL 添加参数并在服务端检索它们

我正在使用 jaxws-rt 并构建了 WSDL 并创建了所有 Web 服务。一切正常,但我想知道是否有办法查看是否有更多参数被标记到来自 Web 服务的 URL 上。

java jax-ws

2
推荐指数
1
解决办法
9851
查看次数

javax.xml.ws.WebServiceException:方法X暴露为WebMethod,但是没有对应的wsdl操作

我正在使用 JAX-WS RI 与第三方 Web 服务 (Adyen) 集成。我已经下载了他们的 wsdl 副本,并jaxws:wsdl2java在我的构建中使用以生成 Web 服务实现源代码。在运行时,当我尝试通过调用我自动生成的支付服务类的 getPort() 方法来设置端口时,我收到以下异常,声称有一个公开的方法,但它不存在于 wsdl portType 元素中:

javax.xml.ws.WebServiceException: Method adjustAuthorisation is exposed as WebMethod, but there is no corresponding wsdl operation with name {http://payment.services.adyen.com}adjustAuthorisation in the wsdl:portType{http://payment.services.adyen.com}PaymentPortType
Run Code Online (Sandbox Code Playgroud)

但是,它存在于 portType 元素中。这是 wsdl 的相关片段:

javax.xml.ws.WebServiceException: Method adjustAuthorisation is exposed as WebMethod, but there is no corresponding wsdl operation with name {http://payment.services.adyen.com}adjustAuthorisation in the wsdl:portType{http://payment.services.adyen.com}PaymentPortType
Run Code Online (Sandbox Code Playgroud)

完整的 wsdl 可以在这里看到:https ://pal-live.adyen.com/pal/servlet/Payment/v30?wsdl

wsdl 包含在具有类路径 /wsdl/Payment.wsdl 的目标 jar 中。我在运行时使用配置类中的代码加载它:

<wsdl:portType name="PaymentPortType">
  <wsdl:operation name="adjustAuthorisation">
    <wsdl:input …
Run Code Online (Sandbox Code Playgroud)

java soap wsdl web-services jax-ws

2
推荐指数
1
解决办法
1937
查看次数

来自 jaxws-tools:3.0.0 的 Wsimport 在 ClassNotFoundException 上崩溃

当我将 jaxws-tools 升级到 3.0.0 时,我的 wsimport Gradle 任务开始因 ClassNotFoundException 崩溃。

我有一个使用 Springinitializr 创建的简单 Gradle 项目。我其中有一个 wsimport 任务,是我根据 gradle wsimport问题以及其他来源创建的。build.gradle 如下所示

plugins {
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    jaxws
}

task wsimport {
    description = 'Generate classes from wsdl using wsimport'

    def wsdlFile = file("${projectDir}/src/main/resources/soap/wsdl/hello.wsdl")
    ext.classesDir = "${buildDir}/classes/generated"

    doLast {
        ant {
            mkdir(dir: classesDir)

            taskdef(name: 'wsimport',
                    classname: 'com.sun.tools.ws.ant.WsImport',
                    classpath: configurations.jaxws.asPath
            )
            wsimport(
                    destdir: …
Run Code Online (Sandbox Code Playgroud)

java jax-ws wsimport gradle

2
推荐指数
1
解决办法
4472
查看次数

Jersey的新功能 - 在资源中获取不受支持的媒体类型

我是泽西和REST的新手所以请原谅,如果我的问题太愚蠢了.我有一个名为Places的简单资源,它应该支持一个GET基于输入变量返回一些兴趣点的操作.这是输入字符串和类:

错误:

HTTP 415 - Unsupported Media Type
Run Code Online (Sandbox Code Playgroud)

输入网址:

http://localhost:8080/RESTGO/rest/places?latitude=2&longitude=3&radius=3&types=food
Run Code Online (Sandbox Code Playgroud)

类:

@Path("/places")
public class Places {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public JSONObject getPlaces(@QueryParam("latitude") double latitude,
            @QueryParam("longitude") double longitude,
            @QueryParam("radius") int radius,
            @QueryParam("types") String types,
            @DefaultValue("true") boolean sensor) {
        GooglePlacesClient google = new GooglePlacesClient();
        JSONObject json = null;

        try {
            String response = google.performPlacesSearch(latitude, longitude, radius, types, sensor);
            json = new JSONObject(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
}
Run Code Online (Sandbox Code Playgroud)

rest json jax-ws jersey

1
推荐指数
1
解决办法
3000
查看次数

java中的多维数据结构

我需要创建一个具有以下语法的数据结构:

[
 status: "success",
 statusDescription: "statusDescription"
 count: "5",
 states: [
  [stateId: "1", stateDescription: "1 description"],
  [stateId: "2", stateDescription: "2 description"],
  [stateId: "3", stateDescription: "3 description"],
  [stateId: "4", stateDescription: "4 description"],
  [stateId: "5", stateDescription: "5 description"]

 ]
]
Run Code Online (Sandbox Code Playgroud)

我不确定如何在Java中这样做.我正在尝试ArrayLists和Maps的各种组合,但是不能完全得到它.

编辑:我实际上需要返回此数据类型作为对JAX-WS @WebMethod调用的响应.创建一个单独的类,尤其是具有List元素的类会导致问题.

java arrays jax-ws map data-structures

1
推荐指数
1
解决办法
1423
查看次数

使用jax-ws调用位于负载均衡器上的Web服务,返回http状态为302,但是当我使用SoapUI时它工作正常

当我使用jax-ws调用位于负载均衡器上的Web服务时,它会返回

服务器发送HTTP状态码302:暂时移动

然后失败,但是当我使用SoapUI时它工作正常.

有没有办法可以配置服务来正确处理这个问题?

我使用wsimport并生成Web服务代码并进行调用

NotificationWebService service = new NotificationWebService(wsdlLocation, qName);
NotificationWebServiceSoap serviceSoap = service.getNotificationWebServiceSoap();
String xmlString = serviceSoap.getRSAPublicKeyXMLString();
Run Code Online (Sandbox Code Playgroud)

我被困住了,我无法在任何地方找到解决方案,所以任何帮助都会受到赞赏.

java soap web-services load-balancing jax-ws

1
推荐指数
1
解决办法
1万
查看次数

如何在CXF中修改JAX-WS响应的HTTP头?

我一直致力于开发安全代理后面的CXF Web服务,该代理要求在服务调用之前进行HTTP基本身份验证.这些服务彼此之间进行通信,并要求对请求和响应进行身份验证.

到目前为止,我已经能够通过HTTPConduit为请求设置HTTP基本身份验证,如下所示:

    Client client = ClientProxy.getClient(port);
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
    authorizationPolicy.setUserName(username);
    authorizationPolicy.setPassword(password);
    authorizationPolicy.setAuthorizationType("Basic");
    conduit.setAuthorization(authorizationPolicy);
Run Code Online (Sandbox Code Playgroud)

在每个服务方法调用上调用上面的方法,并且我以正式的形式获得正确的入站消息

INFO: Inbound Message
----------------------------
ID: 1
Address: http://someURL/someService?wsdl
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml; charset=UTF-8
Headers: {Accept=[*/*], Authorization=[Basic {TOKEN}], 
                cache-control=[no-cache], connection=[keep-alive], 
                Content-Length=[735], content-type=[text/xml; charset=UTF-8], 
                pragma=[no-cache], ...}
Payload: <soap:Envelope>...</soap:Envelope>
--------------------------------------
Run Code Online (Sandbox Code Playgroud)

但是,响应不包含所需的标头

INFO: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope/">...</soap:Envelope>
--------------------------------------
Run Code Online (Sandbox Code Playgroud)

如何修改响应HTTP标头?我试过了

((BindingProvider)port).getResponseContext().put(
           MessageContext.HTTP_RESPONSE_HEADERS, 
           Collections.singletonMap("Authentication", 
           Collections.singletonList("Basic "+token)));
Run Code Online (Sandbox Code Playgroud)

没有得到理想的结果.

cxf header http response jax-ws

1
推荐指数
1
解决办法
5368
查看次数