---
title: "Converting Proxies to Strings"
url: https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Converting Proxies to Strings

Parts of this page are for some programming languages only, and name them. For one language's text alone, see [C++](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/php.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/ruby.md), and [Swift](https://docs.zeroc.com/ice/3.8/runtime/invocation/converting-proxies-to-strings/swift.md).

This page describes how an application can *stringify* a proxy and create a property dictionary that captures all the proxy's properties.

## Stringifying a Proxy

> **C++**
>
> You can stringify a proxy by calling `ice_toString` on this proxy. For example:
>
> ```cpp
> GreeterPrx greeter{communicator, "greeter:tcp -h localhost -p 4061"};
> std::string s = greeter.ice_toString();
> ```
>
> `ice_toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/cpp.md#ice.tostringmode) property.

> **C#**
>
> You can stringify a proxy by calling `ToString` on this proxy. For example:
>
> ```csharp
> GreeterPrx greeter = GreeterPrxHelper.createProxy(
>     communicator,
>     "greeter:tcp -h localhost -p 4061");
> string s = greeter.ToString();
> ```
>
> `ToString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/csharp.md#ice.tostringmode) property.

> **Java**
>
> You can stringify a proxy by calling `toString` on this proxy. For example:
>
> ```java
> GreeterPrx greeter = GreeterPrx.createProxy(
>     communicator,
>     "greeter:tcp -h localhost -p 4061");
> String s = greeter.toString();
> ```
>
> `toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/java.md#ice.tostringmode) property.

> **JavaScript**
>
> You can stringify a proxy by calling `toString` on this proxy. For example:
>
> ```js
> const greeter = new GreeterPrx(communicator, "greeter:tcp -h localhost -p 4061");
> const s = greeter.toString();
> ```
>
> `toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/js.md#ice.tostringmode) property.

> **MATLAB**
>
> You can stringify a proxy by calling `ice_toString` on this proxy. For example:
>
> ```matlab
> greeter = GreeterPrx(communicator, 'greeter:tcp -h localhost -p 4061');
> s = greeter.ice_toString();
> ```
>
> `ice_toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/matlab.md#ice.tostringmode) property.

> **PHP**
>
> You can stringify a proxy by calling `ice_toString` on this proxy. For example:
>
> ```php
> $greeter = GreeterPrxHelper::createProxy(
>     $communicator,
>     "greeter:tcp -h localhost -p 4061");
> $s = $greeter->ice_toString();
> ```
>
> `ice_toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/php.md#ice.tostringmode) property.

> **Python**
>
> You can stringify a proxy by calling `ice_toString` on this proxy. For example:
>
> ```py
> greeter = VisitorCenter.GreeterPrx(
>     communicator,
>     "greeter:tcp -h localhost -p 4061")
> s = greeter.ice_toString()
>
> # Or
>
> s = str(greeter)
> ```
>
> `ice_toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/python.md#ice.tostringmode) property.

> **Ruby**
>
> You can stringify a proxy by calling `ice_toString` on this proxy. For example:
>
> ```ruby
> greeter = VisitorCenter::GreeterPrx.new(
>     communicator,
>     "greeter:tcp -h localhost -p 4061")
> s = greeter.ice_toString()
> ```
>
> `ice_toString` stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/ruby.md#ice.tostringmode) property.

> **Swift**
>
> You can stringify a proxy by calling `ice_toString` on this proxy, or by reading its `description` property (from protocol [CustomStringConvertible](https://developer.apple.com/documentation/swift/customstringconvertible)). For example:
>
> ```swift
> let greeter = try makeProxy(
>     communicator: communicator,
>     proxyString: "greeter:tcp -h localhost -p 4061",
>     type: GreeterPrx.self)
>
> let s = greeter.description;
> ```
>
> `ice_toString` (or `description`, which is equivalent) stringifies non-printable ASCII characters and non-ASCII characters in the proxy's identity, facet and adapter ID as specified through the [Ice.ToStringMode](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties/swift.md#ice.tostringmode) property.

## Proxy to Property

You can also perform a deeper proxy stringification by calling `proxyToProperty` on your communicator. For example:

> **C++**
>
> ```cpp
> GreeterPrx greeter{communicator, "greeter:tcp -h localhost -p 4061"};
> Ice::PropertyDict propertyMap =
>     communicator->proxyToProperty(greeter, "Greeter");
> ```

> **C#**
>
> ```csharp
> GreeterPrx greeter =
>     GreeterPrxHelper.createProxy(communicator, "greeter:tcp -h localhost -p 4061");
> Dictionary<string, string> propertyDict =
>     communicator.proxyToProperty(greeter, "Greeter");
> ```

> **Java**
>
> ```java
> GreeterPrx greeter = GreeterPrx.createProxy(
>     communicator,
>     "greeter:tcp -h localhost -p 4061");
> Map<String, String> propertyDict =
>     communicator.proxyToProperty(greeter, "Greeter");
> ```

> **JavaScript**
>
> ```js
> const greeter = new GreeterPrx(
>     communicator,
>     "greeter:tcp -h localhost -p 4061");
> const propertyDict = communicator.proxyToProperty(greeter,"Greeter");
> ```

> **MATLAB**
>
> ```matlab
> greeter = GreeterPrx(communicator, 'greeter:tcp -h localhost -p 4061');
> propertyDict = communicator.proxyToProperty(greeter, 'Greeter');
> ```

> **PHP**
>
> ```php
> $greeter = GreeterPrxHelper::createProxy(
>     $communicator,
>     "greeter:tcp -h localhost -p 4061");
> $propertyDict = $communicator->proxyToProperty($greeter, "Greeter");
> ```

> **Python**
>
> ```py
> greeter = VisitorCenter.GreeterPrx(
>     communicator,
>     "greeter:tcp -h localhost -p 4061")
> propertyDict: dict[str, str] = communicator.proxyToProperty(greeter, "Greeter")
> ```

> **Ruby**
>
> ```ruby
> greeter = VisitorCenter::GreeterPrx.new(
>     communicator,
>     "greeter:tcp -h localhost -p 4061")
> propertyDict = communicator.proxyToProperty(greeter, "Greeter")
> ```

> **Swift**
>
> ```swift
> let greeter = try makeProxy(
>     communicator: communicator,
>     proxyString: "greeter:tcp -h localhost -p 4061",
>     type: GreeterPrx.self)
> let proxyDict = communicator.proxyToProperty(proxy: greeter, property: "Greeter")
> ```

The resulting map or dictionary holds all the [proxy properties](https://docs.zeroc.com/ice/3.8/property-reference/proxy-properties.md) for the supplied proxy, except its [Context](https://docs.zeroc.com/ice/3.8/property-reference/proxy-properties.md#name.context.key) properties. The second parameter of `proxyToProperty` is the base name for the [properties](https://docs.zeroc.com/ice/3.8/runtime/properties-and-configuration/properties-overview.md) in the returned map.

## See Also

- [Obtaining Proxies](https://docs.zeroc.com/ice/3.8/runtime/invocation/creating-proxies.md)
- [Proxy and Endpoint Syntax](https://docs.zeroc.com/ice/3.8/runtime/endpoint-syntax.md)
- [Proxy Properties](https://docs.zeroc.com/ice/3.8/property-reference/proxy-properties.md)
