gpt4 book ai didi

java - 如何将 FastInfoset 与 JAXWS 一起使用?

转载 作者:搜寻专家 更新时间:2023-11-01 02:17:58 24 4
gpt4 key购买 nike

根据我能找到的内容,我得到的代码看起来应该是正确的,但大量输出并不表明它正在使用 FastInfoset。我的理解是 Accept 应该表明它可以接受 Fastinfoset 并且响应实际上会使用它,这意味着它不是 text/xml 作为响应类型。知道我做错了什么吗?我用 Google 进行了搜索,但很难找到有关如何使用 FastInfoset 的详细信息。

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass( C360Server.class);
factory.setAddress("http://localhost:8501/cxfcontroller/cl_v5");
C360Server client = (C360Server)factory.create();
((BindingProvider)client).getRequestContext().put(
"com.sun.xml.ws.client.ContentNegotiation", "optimistic");

C360Request requestTrans = new C360Request();
... code to fill in the request ...
C360Response response = client.findContacts( requestTrans );

尽管日志记录似乎并未表明甚至尝试过 FastInfoset:

INFO: Outbound Message
---------------------------
ID: 1
Address: http://localhost:8501/cxfcontroller/cl_v5
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""], Authorization=[Basic cWFfc3VwZXI6cWFfc3VwZXI=], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:findContacts>...bunch of xml deleted for brevity...</ns1:findContacts></soap:Body></soap:Envelope>
--------------------------------------
May 17, 2010 3:23:45 PM org.apache.cxf.interceptor.LoggingInInterceptor logging
INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=[611], Server=[Jetty(6.1.x)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:findContactsResponse>...bunch of xml spew deleted for brevity...</ns1:findContactsResponse></soap:Body></soap:Envelope>
--------------------------------------

知道我做错了什么吗?即使服务器不支持 FastInfoset,我仍然应该在请求中看到尝试协商,对吗?

最佳答案

答案是我掌握的关于如何启用它的信息已经过时了。以下工作在客户端(可能是服务器端,但我已经启用了一个 Spring 配置来处理它)。

           JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
// This enables FastInfoset as the communication protocol
factory.getInInterceptors().add( new FIStaxInInterceptor() );
factory.getOutInterceptors().add( new FIStaxOutInterceptor() );
... other code to set username, location, etc. goes here.
client = (C360Server) factory.create();

关于java - 如何将 FastInfoset 与 JAXWS 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2853365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com