The HTTP component does not perform any SOAP encoding. So it either
assumes that you are talking to a REST service or that the XML its given
is already encoded in SOAP format.
So either
* wrap the XML request with a <soap:Envelope><soap:Body>...
* use the SAAJ component
* use WSIF component
* use the XFire component
i.e. use a real SOAP stack to do the SOAP invocation.
http://servicemix.org/SAAJ
http://servicemix.org/WSIF
http://servicemix.org/XFire
James
stephen pasco wrote:
Hi,
I'm trying to take the http-binding example one step further and connect
to on of ESRI's web services.
I continually end up with the following Exception and I'm not sure how
to resolve the issue. I've highlighted in Bold below the Exception. I'm
including my soap request xml file and the client code. Any help would
be greatly appreciated.
Thank you,
Stephen
Server output:
run:
[echo] Running example client
[java] <?xml version="1.0" encoding="UTF-8"?>
[java] <soap:Envelope
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns5="http://www.themindelectric.com/package/com.esri.is.services
.common.v2/"
xmlns:ns6="http://www.themindelectric.com/package/java.lang/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas
<http://www.themindelectric.com/package/java.lang/"xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:soapenc="http://schemas>.
xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<http://xmlsoap.org/soap/encoding/"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">><soap:Body><soap:Fault><faultcode
>soap:Server</faultcode><faultstring>1019: Error decoding
token.</faultstring><detail><stacktrace>com.esri.is.services.common.v2.ServiceException:
1019: Error d
ecoding token.
[java] at
com.esri.is.services.glue.v2.common.WebServiceTrans.start(WebServiceTrans.java:119)
[java] at
com.esri.is.services.glue.v2.common.WebServiceTrans.start(WebServiceTrans.java:28)
[java] at
com.esri.is.services.glue.v2.common.WebServiceTrans.start(WebServiceTrans.java:23)
[java] at
com.esri.is.services.glue.v2.addressfinder.AddressFinder.findAddress(AddressFinder.java:249)
[java] at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown
Source)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at electric.util.reflect.Invocation.execute(Unknown Source)
[java] at electric.util.reflect.Invocation.invoke(Unknown Source)
[java] at electric.service.object.ObjectService.invoke(Unknown
Source)
[java] at electric.soap.SOAPHandler.invokeOnService(Unknown Source)
[java] at electric.soap.SOAPHandler.invoke(Unknown Source)
[java] at electric.soap.http.SOAPHTTPHandler.service(Unknown
Source)
[java] at electric.server.http.ServletServer.service(Unknown
Source)
[java] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
[java] at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:444)
[java] at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:363)
[java] at
com.esri.is.core.util.HttpForward.processRequest(HttpForward.java:50)
[java] at
com.esri.is.core.util.HttpForward.doPost(HttpForward.java:68)
[java] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[java] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at
org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
[java] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:309)
[java] at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[java] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
[java] at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[java] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
[java] at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
[java] at
com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
[java] at
com.iplanet.ias.web.WebContainer.service(WebContainer.java:848)
[java] </stacktrace></detail><tme:exception
xmlns:tme="http://www.themindelectric.com/"
<http://www.themindelectric.com/">>
servicemix.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:my="http://servicemix.org/demo/"
<http://servicemix.org/demo/">>
<!-- the JBI container -->
<container id="jbi">
<property name="useMBeanServer" value="true"/>
<property name="createMBeanServer" value="true"/>
<property name="dumpStats" value="true"/>
<property name="statsInterval" value="10"/>
<components>
<!-- Create a http server binding on port 8912 and have it
forward to the foo:stockQuote -->
<component id="httpReceiver" service="foo:httpBinding"
endpoint="httpReceiver"
class="org.servicemix.components.http.HttpConnector"
destinationService="foo:stockQuote">
<property name="host" value="localhost"/>
<property name="port" value="8912"/>
</component>
<!-- This just invokes another service -->
<!--
<component id="stockQuote" service="foo:stockQuote"
endpoint="stockQuote" class="org.servicemix.components.saaj.SaajBinding">
<property name="soapEndpoint">
<bean class="javax.xml.messaging.URLEndpoint">
<constructor-arg value="http://64.124.140.30/soap"/
<http://64.124.140.30/soap"/>>
</bean>
</property>
</component>
-->
<component id="stockQuote" service="foo:stockQuote"
endpoint="stockQuote" class="org.servicemix.components.saaj.SaajBinding">
<property name="soapEndpoint">
<bean class="javax.xml.messaging.URLEndpoint">
<constructor-arg
value="http://arcweb.esri.com/services/v2/AddressFinder"/
<http://arcweb.esri.com/services/v2/AddressFinder"/>>
</bean>
</property>
</component>
</components>
</container>
</beans>
Soap request xml:
<findAddress xmlns:m="AddressFinder"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m0="http://www.themindelectric.com/package/com.esri.is.services.glue.v2.addressfinder/"
<http://www.themindelectric.com/package/com.esri.is.services.glue.v2.addressfinder/">>
<address xsi:type="m0:Address">
<houseNumber xsi:type="xsd:string">380</houseNumber>
<street xsi:type="xsd:string">New York St</street>
<city xsi:type="xsd:string">Redlands</city>
<state_prov xsi:type="xsd:string">CA</state_prov>
<zone xsi:type="xsd:string">92373</zone>
<country xsi:type="xsd:string">US</country>
</address>
<addressFinderOptions xsi:type="m0:AddressFinderOptions">
<dataSource xsi:type="xsd:string">GDT.Address.US
<http://GDT.Address.US></dataSource>
</addressFinderOptions>
<token xsi:type="xsd:string">MyToken</token>
</findAddress>
Client code:
public class HttpClient {
public static void main(String[] args) throws Exception {
URLConnection connection = new
URL("http://localhost:8912").openConnection()
<http://localhost:8912").openConnection()>;
// URLConnection connection = new
URL("http://arcweb.esri.com/services/v2/AddressFinder.wsdl").openConnection()
<http://arcweb.esri.com/services/v2/AddressFinder.wsdl").openConnection()>;
connection.setDoOutput(true);
OutputStream os = connection.getOutputStream();
// Post the request file.
FileInputStream fis = new
FileInputStream("ESRI_FindAddressRequest.xml");
int c;
while ((c = fis.read()) >= 0) {
os.write(c);
}
os.close();
fis.close();
// Read the response.
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
}
}
--
James
-------
http://radio.weblogs.com/0112098/