• Fabian
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hey everybody,

 

I am trying to callout to a webservice that delivers a soap-response like following:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
        <ns1:getDataResponse xmlns:ns1="http://www.customer.com/namespace1">
            <ns1:Response>
                <ns1:SomeElement>
                    <ns1:ParentObjectType xsi:type="ns2:ChildObjectType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://www.customer.com/namespace2">
                        <SomeChildObjectProperty>
                            SomeChildObjectPropertyValue
                        </SomeChildObjectProperty>
                    </ns1:ParentObjectType>
                </ns1:SomeElement>
            </ns1:Response>
        </ns1:getDataResponse xmlns:ns1="http://www.customer.com/namespace1">
    </soapenv:Body>
</soapenv:Envelope>

 In apex, definition is as following (generated from wsdl with small changes):

public class Namespace1 {
    public class getDataResponse {
        ...
    }
    public class Response {
        ...
    }
    public class SomeElement {
        ...
    }
    //virtual was added manually
    public virtual class ParentObjectType {
        ...
    }
}

public class Namespace2 {
    //extends Namespace1.ParentObjectType was added manually
    public class ChildObjectType extends Namespace1.ParentObjectType {
        public String SomeChildObjectProperty;
        ...
    }
}

The problem is, that apex is unable to parse the webservice response and tells me, that "apextype for http://www.customer.com/namespace1=ParentObjectType cannot be found".

 

Any Ideas on this? I'm really confused, as anything else seems to work fine. 

  • February 25, 2013
  • Like
  • 0

Summary

A class implementing an override for public String toString() will not have this function honored by String.join(). Instead, it returns the name of the class. Using the normal concatenation operator on the list yields output that is expected.

 

Repro



<apex:page controller="repro">
    <table>
        <tbody>
            <tr>
                <td>new sub1().tostring()</td>
                <td>{!Sub1ToString}</td>
            </tr>
            <tr>
                <td>''+(new sub1[] { new sub1() })</td>
                <td>{!Sub1AsList}</td>
            </tr>
            <tr>
                <td>string.join(new sub1[] { new sub1() }, '')</td>
                <td>{!Sub1AsJoin}</td>
            </tr>
            <tr>
                <td>new sub2().tostring()</td>
                <td>{!Sub2ToString}</td>
            </tr>
            <tr>
                <td>''+(new sub2[] { new sub2() })</td>
                <td>{!Sub2AsList}</td>
            </tr>
            <tr>
                <td>string.join(new sub2[] { new sub2() }, '')</td>
                <td>{!Sub2AsJoin}</td>
            </tr>
        </tbody>
    </table>
</apex:page>

 

public with sharing class repro {
    class sub1 {
    
    }
    
    class sub2 {
        public override string tostring() {
            return 'Hello. I am sub2.';
        }
    }
    
    public string getSub1ToString() {
        return new sub1().tostring();
    }
    
    public string getSub1AsJoin() {
        return string.join(new sub1[] { new sub1() }, '');
    }

    public string getSub1AsList() {
        return ''+(new sub1[] { new sub1() });
    }
    
    public string getSub2ToString() {
        return new sub2().tostring();
    }
    
    public string getSub2AsJoin() {
        return string.join(new sub2[] { new sub2() }, '');
    }
    
    public string getSub2AsList() {
         return ''+(new sub2[] { new sub2() });
   }
}

 Output from above:

 

new sub1().tostring()sub1:[]
''+(new sub1[] { new sub1() })(sub1:[])
string.join(new sub1[] { new sub1() }, '')repro$sub1
new sub2().tostring()Hello. I am sub2.
''+(new sub2[] { new sub2() })(Hello. I am sub2.)
string.join(new sub2[] { new sub2() }, '')

repro$sub2

 

As one can see, It's not even trying to join them together, it's just calling some sort of odd "List<Object>.getType()" function that we can't even access.

 

I've logged a case with support, but since I'm half-expecting them to just close it without even trying to log a bug, I'm also posting this here hoping that some PM or internal salesforce.com developer will see this and have it fixed at some point.

Hi,

I am accessing custom setting values in my apex code and its working fine. When I am calling it through test class then No values gets in from Custom Setting. It always blank in test class. Can somebody help me to understand why custom settings values are not accessible in test class.

 

Thanks,

Vinod Kumar

Summary

A class implementing an override for public String toString() will not have this function honored by String.join(). Instead, it returns the name of the class. Using the normal concatenation operator on the list yields output that is expected.

 

Repro



<apex:page controller="repro">
    <table>
        <tbody>
            <tr>
                <td>new sub1().tostring()</td>
                <td>{!Sub1ToString}</td>
            </tr>
            <tr>
                <td>''+(new sub1[] { new sub1() })</td>
                <td>{!Sub1AsList}</td>
            </tr>
            <tr>
                <td>string.join(new sub1[] { new sub1() }, '')</td>
                <td>{!Sub1AsJoin}</td>
            </tr>
            <tr>
                <td>new sub2().tostring()</td>
                <td>{!Sub2ToString}</td>
            </tr>
            <tr>
                <td>''+(new sub2[] { new sub2() })</td>
                <td>{!Sub2AsList}</td>
            </tr>
            <tr>
                <td>string.join(new sub2[] { new sub2() }, '')</td>
                <td>{!Sub2AsJoin}</td>
            </tr>
        </tbody>
    </table>
</apex:page>

 

public with sharing class repro {
    class sub1 {
    
    }
    
    class sub2 {
        public override string tostring() {
            return 'Hello. I am sub2.';
        }
    }
    
    public string getSub1ToString() {
        return new sub1().tostring();
    }
    
    public string getSub1AsJoin() {
        return string.join(new sub1[] { new sub1() }, '');
    }

    public string getSub1AsList() {
        return ''+(new sub1[] { new sub1() });
    }
    
    public string getSub2ToString() {
        return new sub2().tostring();
    }
    
    public string getSub2AsJoin() {
        return string.join(new sub2[] { new sub2() }, '');
    }
    
    public string getSub2AsList() {
         return ''+(new sub2[] { new sub2() });
   }
}

 Output from above:

 

new sub1().tostring()sub1:[]
''+(new sub1[] { new sub1() })(sub1:[])
string.join(new sub1[] { new sub1() }, '')repro$sub1
new sub2().tostring()Hello. I am sub2.
''+(new sub2[] { new sub2() })(Hello. I am sub2.)
string.join(new sub2[] { new sub2() }, '')

repro$sub2

 

As one can see, It's not even trying to join them together, it's just calling some sort of odd "List<Object>.getType()" function that we can't even access.

 

I've logged a case with support, but since I'm half-expecting them to just close it without even trying to log a bug, I'm also posting this here hoping that some PM or internal salesforce.com developer will see this and have it fixed at some point.