我正在尝试调用服务来获取温度并将结果传递给另一个服务,以达到华氏度到摄氏度,但是当我执行服务时会出现异常。
<!-- temperatura BPEL Process [Generated by the Eclipse BPEL Designer] -->
<!-- Date: Tue May 12 10:40:32 CEST 2015 -->
<bpel:process name="temperatura"
targetNamespace="http://ws.temperatura.tps"
suppressJoinFailure="yes"
xmlns:tns="http://ws.temperatura.tps"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:ns="http://ws.cdyne.com/WeatherWS/" xmlns:ns0="http://www.w3schools.com/webservices/">
<!-- Import the client WSDL -->
<bpel:import namespace="http://www.w3schools.com/webservices/" location="tempconvert.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
<bpel:import namespace="http://ws.cdyne.com/WeatherWS/" location="WeatherSoap.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
<bpel:import location="temperaturaArtifacts.wsdl" namespace="http://ws.temperatura.tps"
importType="http://schemas.xmlsoap.org/wsdl/" />
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:partnerLinks>
<!-- The 'client' role represents the requester of this service. -->
<bpel:partnerLink name="client"
partnerLinkType="tns:temperatura"
myRole="temperaturaProvider"
/>
<bpel:partnerLink name="WeatherPL" partnerLinkType="tns:WeatherPLT" partnerRole="WeatherRole"></bpel:partnerLink>
<bpel:partnerLink name="ConverterPL" partnerLinkType="tns:ConverterPLT" partnerRole="ConverterRole"></bpel:partnerLink>
</bpel:partnerLinks>
<!-- ================================================================= -->
<!-- VARIABLES -->
<!-- List of messages and XML documents used within this BPEL process -->
<!-- ================================================================= -->
<bpel:variables>
<!-- Reference to the message passed as input during initiation -->
<bpel:variable name="input"
messageType="tns:temperaturaRequestMessage"/>
<!--
Reference to the message that will be returned to the requester
-->
<bpel:variable name="output"
messageType="tns:temperaturaResponseMessage"/>
<bpel:variable name="WeatherPLResponse" messageType="ns:GetCityWeatherByZIPSoapOut"></bpel:variable>
<bpel:variable name="WeatherPLRequest" messageType="ns:GetCityWeatherByZIPSoapIn"></bpel:variable>
<bpel:variable name="ConverterPLResponse" messageType="ns0:FahrenheitToCelsiusSoapOut"></bpel:variable>
<bpel:variable name="ConverterPLRequest" messageType="ns0:FahrenheitToCelsiusSoapIn"></bpel:variable>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence name="main">
<!-- Receive input from requester.
Note: This maps to operation defined in temperatura.wsdl
-->
<bpel:receive name="receiveInput" partnerLink="client"
portType="tns:temperatura"
operation="process" variable="input"
createInstance="yes"/>
<!-- Generate reply to synchronous request -->
<bpel:assign validate="no" name="AssignInput">
<bpel:copy>
<bpel:from><bpel:literal><tns:GetCityWeatherByZIP xmlns:tns="http://ws.cdyne.com/WeatherWS/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:ZIP>tns:ZIP</tns:ZIP>
</tns:GetCityWeatherByZIP>
</bpel:literal></bpel:from>
<bpel:to variable="WeatherPLRequest" part="parameters"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="payload" variable="input">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:zipcode]]></bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="WeatherPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns:ZIP]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="InvokeWeather" partnerLink="WeatherPL" operation="GetCityWeatherByZIP" portType="ns:WeatherSoap" inputVariable="WeatherPLRequest" outputVariable="WeatherPLResponse"></bpel:invoke>
<bpel:assign validate="no" name="AssignTemp">
<bpel:copy>
<bpel:from><bpel:literal><tns:FahrenheitToCelsius xmlns:tns="http://www.w3schools.com/webservices/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:Fahrenheit>tns:Fahrenheit</tns:Fahrenheit>
</tns:FahrenheitToCelsius>
</bpel:literal></bpel:from>
<bpel:to variable="ConverterPLRequest" part="parameters"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="WeatherPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns:GetCityWeatherByZIPResult/ns:Temperature]]></bpel:query>
</bpel:from>
<bpel:to part="parameters" variable="ConverterPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns0:Fahrenheit]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="InvokeTemp" partnerLink="ConverterPL" operation="FahrenheitToCelsius" portType="ns0:TempConvertSoap" inputVariable="ConverterPLRequest" outputVariable="ConverterPLResponse"></bpel:invoke>
<bpel:assign validate="no" name="AssignOuput">
<bpel:copy>
<bpel:from><bpel:literal><tns:temperaturaResponse xmlns:tns="http://ws.temperatura.tps" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:temp>tns:temp</tns:temp>
</tns:temperaturaResponse>
</bpel:literal></bpel:from>
<bpel:to variable="output" part="payload"></bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from part="parameters" variable="ConverterPLResponse">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns0:FahrenheitToCelsiusResult]]></bpel:query>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:temp]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="replyOutput"
partnerLink="client"
portType="tns:temperatura"
operation="process"
variable="output"
/>
</bpel:sequence>
</bpel:process>
当我执行服务时,我得到了这个异常
<?xml version="1.0" encoding="UTF-8"?>
<message><parameters><GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><GetCityWeatherByZIPResult xmlns="http://ws.cdyne.com/WeatherWS/"><Success xmlns="http://ws.cdyne.com/WeatherWS/">true</Success><ResponseText xmlns="http://ws.cdyne.com/WeatherWS/">City Found</ResponseText><State xmlns="http://ws.cdyne.com/WeatherWS/">NY</State><City xmlns="http://ws.cdyne.com/WeatherWS/">New York</City><WeatherStationCity xmlns="http://ws.cdyne.com/WeatherWS/">White Plains</WeatherStationCity><WeatherID xmlns="http://ws.cdyne.com/WeatherWS/">15</WeatherID><Description xmlns="http://ws.cdyne.com/WeatherWS/">N/A</Description><Temperature xmlns="http://ws.cdyne.com/WeatherWS/">63</Temperature><RelativeHumidity xmlns="http://ws.cdyne.com/WeatherWS/">87</RelativeHumidity><Wind xmlns="http://ws.cdyne.com/WeatherWS/">E7</Wind><Pressure xmlns="http://ws.cdyne.com/WeatherWS/">29.97S</Pressure><Visibility xmlns="http://ws.cdyne.com/WeatherWS/"/><WindChill xmlns="http://ws.cdyne.com/WeatherWS/"/><Remarks xmlns="http://ws.cdyne.com/WeatherWS/"/></GetCityWeatherByZIPResult></GetCityWeatherByZIPResponse></parameters></message>
11:15:44,686 ERROR [ExternalService] Error sending message (mex={PartnerRoleMex#hqejbhcnphraa13wrt34ru [PID {http://ws.temperatura.tps}temperatura-178] calling org.apache.ode.bpel.epr.WSAEndpoint@4d15bb4f.FahrenheitToCelsius(...) Status ASYNC}): Transport error: 411 Error: Length Required
org.apache.axis2.AxisFault: Transport error: 411 Error: Length Required
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:298)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:192)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.ode.axis2.SoapExternalService$1$1.call(SoapExternalService.java:206)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
该服务期待内容长度标题。
添加以下属性: