# XML-RPC

**XML-RPC**는 HTTP POST를 통해서 XML 메시지를 주고 받습니다.

## 요청

```
POST /xml-rpc HTTP/1.0
Host: example.com
Content-Type: text/xml

<?xml version="1.0">
<methodCall>
    <methodName>doSomething</methodName>
    <params>
        <param>
            <value><integer>100</integer></value>
        </param>
    </params>
</methodCall>
```

## 응답

서버 오류 등이 아닌 경우에는 `200OK`를 응답해야 합니다.

```
HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0">
<methodResponse>
    <params>
        <param><string>Hello</string></param>
    </params>
</methodResponse>
```

### 오류 응답

```
HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0">
<methodResponse>
    <fault>
        <value>
            <struct>
                <member>
                    <name>faultCode</name>
                    <value><int>4</int></value>
                </member>
                <member>
                    <name>faultString</name>
                    <value><string>Too many parameters.</string></value>
                </member>
            </struct>
        </value>
    </fault>
</methodResponse>
```

## 자료형

자료형이 생략된 경우에는 `string`으로 간주합니다.

- array

  ```xml
  <array>
      <data>
          <value><int>100</int></value>
          <value><int>101</int></value>
          <value><int>102</int></value>
      </data>
  </array>
  ```

- base64

  ```xml
  <base64>aW9...cyE=</base64>
  ```

- boolean

  ```xml
  <boolean>1</boolean>
  ```

- dateTime.iso8601

  ```xml
  <dateTime.iso8601>2021-01-01T00:12:00</dateTime.iso8601>
  ```

- double

  ```xml
  <double>100.0</double>
  ```

- integer

  ```xml
  <int>100</int>
  <i4>100</i4>
  ```

- string

  ```xml
  <string>Hello</string>
  ```

- struct

  ```xml
  <struct>
      <member>
          <name>foo</name>
          <value><int>100</int></value>
      </member>
      <member>
          <name>bar</name>
          <value><string>Hello</string></value>
      </member>
  </struct>
  ```

- nil

  ```xml
  <nil />
  ```


http://xmlrpc.com/