I’m looking for a little help regarding a flow service I have created to receive xml data.
It’s a simple process I’ve usued many times in the past via ftp but a new customer is sending via http:post.
I have tested the process manually via webMethods 4.6 and can use a little client http:post app utility that sends a post. Both work fine.
However when our customer send the xml it fails with the following:
POST /invoke/PMC.METER:MeterIn
00222F [B2BCORE.0038.0002] ← Content-type: text/xml
002230 [B2BCORE.0038.0002] ← User-Agent: Jakarta Commons-HttpClient/3.1
002231 [B2BCORE.0038.0002] ← Host: 130.170.255.160:5555
002232 [B2BCORE.0038.0002] ← Content-Length: 0
002233 [B2BCORE.0049.0005] Invoke : index=1 depth=1
002234 [B2BCORE.0050.0004] Copy failed: (Simple) No source data available: to=/CONTROLAREA(0), from=/rec_MeterIn(0)/CONTROLAREA(0)
002235 [B2BCORE.0050.0004] Copy failed: (Simple) No source data available: to=/DATAAREA(0), from=/rec_MeterIn(0)/DATAAREA(0)
Previously the customer did not have the content-type set to text/xml but the content length was always greater than 0.
Now that they’ve changed the length is zero.
Could they possibly need to set the charset to utf-8?
Here’s the code they are using:
public class TIMQHttpClientCycleCount {
public String paramName = "xmldata";
public String protocol = "http";
public String url = "";
public int timeout = 10000;
public String trustStore = "workordercerf";
public String trustStorePassword = "spring01";
HttpClient client = new HttpClient();
PostMethod method = null;
/**
* @param sUrl
* @param xmlStr
* @return true/false = success/fail
*/
public boolean send(String xmlStr, boolean isdebug) {
if (isdebug)
System.out.println("Begin sending ...");
System.out.println(xmlStr);
if (!(protocol.trim().equals("http"))) {
System.setProperty("javax.net.ssl.trustStore", this.trustStore);
System.setProperty("javax.net.ssl.trustStorePassword",
this.trustStorePassword);
java.security.Security
.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
}
client.getParams().setParameter("http.socket.timeout",
new Integer(timeout));
method = new PostMethod(url);
method.setParameter(this.paramName, xmlStr);
method.setRequestHeader("Content-type", "text/xml");
try {
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
if (isdebug)
System.err.println("Method failed: "
+ method.getStatusLine());
return false;
}
if (isdebug) {
System.out.println("test");
String test = method.getResponseBodyAsString();
String[] tests = test.split("</");
for (int i = 0; i < tests.length; i++) {
String[] innerTests = tests[i].split(">");
if (innerTests.length > 1) {
String result = innerTests[innerTests.length - 1];
if (result.toUpperCase().indexOf("bad".toUpperCase()) != -1) {
return false;
}
}
}
return true;
}
} catch (HttpException e) {
if (isdebug)
System.err.println("Fatal protocol violation: "
+ e.getMessage());
e.printStackTrace();
} catch (IOException e) {
if (isdebug)
System.err.println("Fatal transport error: " + e.getMessage());
e.printStackTrace();
method.releaseConnection();
}
return false;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public void setUrl(String url) {
this.url = url;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public void setTrustStore(String trustStore) {
this.trustStore = trustStore;
}
public void setTrustStorePassword(String trustStorePassword) {
this.trustStorePassword = trustStorePassword;
}
}