当前位置: 首页 > 知识库问答 >
问题:

camel cxf代理不适用于httpendpoint

益思博
2023-03-14

我的要求是有一个代理web服务,它将接收来自客户端的请求,然后通过camel路由,丰富它并将其转发到其他客户端的真实web服务,获得响应并将其发送回原始请求者。

我主要看了camel cxf代理示例(http://camel.apache.org/cxf-proxy-example.html)和camel分布中的camel cxf示例。它与camel cxf proxyand提出的路线非常相似

<from uri="cxf:bean:soapMessageEndpoint?dataFormat=MESSAGE" />
<camel:convertBodyTo type="java.lang.String"></camel:convertBodyTo>
<to ref="XService"></to>

endpoint所在位置

<endpoint id="XService" uri="http://xx.xx.xxx.xx:8080/X_Service" />

<cxf:cxfEndpoint id="soapMessageEndpoint" address="http://localhost:8181/ProviderInformationDirectoryService"  wsdlURL="wsdl/HPD_ProviderInformationDirectory.wsdl" endpointName="s:ProviderInformationDirectory_Port_Soap" serviceName="s:ProviderInformationDirectory_Service" xmlns:s="urn:ihe:iti:hpd:2010"/>

如您所见,第二个服务是超文本传输协议endpoint。首先是camel-cxf代理。我只有wsdl,此时不需要impl.the数据格式是MESSAGE,因为我需要将整个肥皂信封发送到第二个Web服务,并且客户端的请求中有一些有用的标头。但是当我使用示例肥皂信封运行此路由时,它总是会出现500个响应。我认为发送到真正的webservice的消息不是它所期望的。

我尝试了骆驼路线上的跟踪,但没有显示太多。我希望它会显示对超文本传输协议endpoint的真实请求。我尝试配置拦截器,但也没有工作。跟踪只显示以下内容

 Failed delivery for (MessageId: ID-ALHCAN0437-63941-1354828653539-45-2 on ExchangeId: ID-ALHCAN0437-63941-1354828653539-45-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://X:8080/X_Service with statusCode: 500

我还尝试了以下似乎有效的方法

<from uri="cxf:bean:soapMessageEndpoint?dataFormat=MESSAGE" />
<camel:convertBodyTo type="java.lang.String"></camel:convertBodyTo>
<to uri="bean:callRemoteWS"></to>

callRemoteWS(callRemoteMethod)获取soapenvelope作为字符串,并向上述endpoint发出HTTPPost请求,返回响应。

public String callRemoteMethod(String request) throws Exception{



            HttpClient client = new HttpClient();

            BufferedReader br = null;

            PostMethod method = new PostMethod("http://x.x.x.x:8080/X_Service");

            RequestEntity entity =new StringRequestEntity(request); 

            method.setRequestEntity(entity);

            try{
              int returnCode = client.executeMethod(method);

              if (returnCode != HttpStatus.SC_OK) {
                  System.err.println("Method failed: " + method.getStatusLine());
                  return "Error";
                }

                // Read the response body.
                byte[] responseBody = method.getResponseBody();

                System.out.println(new String(responseBody));

                // Deal with the response.
                // Use caution: ensure correct character encoding and is not binary data
               return new String(responseBody);
            } finally {
              method.releaseConnection();
              if(br != null) try { br.close(); } catch (Exception fe) {}
            }

          }

我很困惑为什么带有http webservice的简单camel cxf代理不起作用,而第二个却起作用(它应该而且确实起作用了:P)。我的代码可以吗。我觉得这不对。我很确定某些exchange属性设置错误,或者发送到real webservice的内容错误。从代理获取的内容用于在第二条路由中进行Httppost调用。因此,来自代理的内容不能是错误的。当它从exchange获得并发送到真正的webservice时,出现了一些问题。谁能给它点线索吗。

共有1个答案

邓仲卿
2023-03-14

我认为这是我一个愚蠢的错误。Soap操作标头具有不同的操作,有效负载用于不同的方法。我用有效载荷调用了错误的操作

 类似资料:
  • 问题内容: 我尝试像这样在python中使用https代理: 是从文件读取的代理,格式为ip:port。我在浏览器中检查了这个https代理,它可以工作。但是在python中,此代码挂起了几秒钟,然后出现异常: 我尝试使用socks5代理,它适用于安装了PySocks的socks5代理。但是对于https我有这个例外,有人可以帮我吗 问题答案: 为指定代理列表时,密钥是协议,值是domain /

  • 因此,我正在构建这个游戏和一个地图编辑器/sdk类型的协议。在我运行w7的台式电脑和我的朋友运行w10的笔记本电脑上,一切都工作得非常好。我可以添加对象并四处移动它们(每个对象都有一个自动更新属性窗口),一切都很好。 我目前正在旅行,所以我决定将项目复制到我的macbook上。UI上的一切都仍然有效,除了停止渲染的东西。我知道对象存在于应用程序中,因为我可以单击它们所在的位置,属性更新就像在我的桌

  • 因此,下面的代码适用于一个活动,但当我使用onCreateView将其添加到一个片段中时,应用程序就会崩溃 Fragment公共类步骤扩展Fragment{ 12-13 15:17:15.062 984-984/com.stephenh.daytrack.daytrack.daytrackstephenh E/AndroidRuntime:致命异常:主进程:com.stephenh.daytrac

  • 当我尝试在WSL2终端中打开VS代码时,如下所示: 我得到以下错误: 用sudo启动时: 我在Windows上的路径中添加了VS代码,并安装了WSL Remote 我正在致力于: Windows10Pro 10.0。19041 WSL 2 Ubuntu 20.04 LTS 代码1.47。一,

  • 我正在编写一个 C# 应用程序来解码此字符串: "--W 3原文3 R hcn Rfd Gl tZ SI 6 I jAi L CJ w cm 9 k dW N 0 X 2 lk I jo iO D Q wM DMz MD气LC J 1 cm wi O iI if Sx 7 InN 0 Y XJ 0 X 3 Rp b WU iO iI 3 OS In by b 2 R 1 Y 3 Rfa WQ iO

  • 问题内容: 嗨,我只是简单地尝试在www.example.com上获取h1标签,该标签显示为“ Example Domain”。该代码适用于http://www.example.com,但不适用于https://www.exmaple.com。我该如何解决这个问题?谢谢 问题答案: PhantomJSDriver不支持(所有)DesiredCapabilities。 你会需要: 记录在这里:htt