Reputation: 1
I've got this issue: I'm trying to send a custom xml request using the XmlRpc-Client from Apache. I got an instance of XmlRpcClient and it contains some methods called "execute " and look like this:
public class RPCClient {
public static void main(String[] args) {
try {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://localhost:8888/SOAP"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object[] params = new Object[]{new Integer(4), new Integer(3)};
String myResponse = (String) client.execute("A_Method", params);
System.out.println("Suc " + myResponse);
} catch (Exception e) {
System.out.println("Err " + e.getMessage());
}
}
}
And it is sending this:
POST /SOAP HTTP/1.1
Content-Type: text/xml
User-Agent: Apache XML RPC 3.1.3 (Sun HTTP Transport)
Cache-Control: no-cache
Pragma: no-cache
Host: ***********
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 200
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>A_Method</methodName>
<params>
<param>
<value>
<i4>4</i4>
</value>
</param>
<param>
<value>3</value>
</param>
</params>
</methodCall>
In short, this client have no an "execute" method to receive a simple string, or something alike. So my question is how can I send my custom xml, that should look like this:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:rp="http://www.abcdef.com/GH"xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header> </soapenv:Header>
<soapenv:Body>
<rp:A_Methodsoapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<package xsi:type="xsd:string">string1</package>
<event xsi:type="xsd:string">string2</event>
<fields xsi:type="rp:ArrayOfKeyValuePair" soapenc:arrayType="rp:KeyValuePair[]">
<item xsi:type="rp:KeyValuePair">
<key xsi:type="xsd:string">string3</key>
<value xsi:type="xsd:string">123</value>
</item>
</fields>
</rp:A_Method>
</soapenv:Body></soapenv:Envelope>
thanks in advance!
Upvotes: 0
Views: 1357
Reputation: 10183
The Apache XML-RPC is for communication with the XML-RPC protocol. The message you are trying to send is SOAP, a different protocol (see the question "What's the difference between XML-RPC and SOAP?").
To send this message you can either send it as plain text (if it's only one simple message) using a regular HTTP client, or use a full blown SOAP library.
Upvotes: 0