• Yishay1
  • NEWBIE
  • 5 Points
  • Member since 2013

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

I need to encode an attachment in ANSI format.
I thought this will work:
Attachment att = new Attachment (
            ParentId = parentObjectId,
            Name = fileName,
            Body = Blob.valueOf(body),
            ContentType = 'text/plain; charset=ansi'
        );

But when I download the attachment it was still UTF-8.
Any ideas?
Thanks in advance,
Yishay

Hi,

 

I found only 2 messages regarding the above exception and none of them helped me.

Can anyone explain me when this happens?

 

I'm trying to connect to the attached WSDL with no success.

Any help will be appreciated.

Thanks,

Yishay

 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://example.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax24="http://text.lowagie.com/xsd" xmlns:ax21="http://io.java/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://example.com">
<wsdl:documentation>
Example
</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax28="http://example.com/xsd" xmlns:ax26="http://text.lowagie.com/xsd" xmlns:ax23="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.com">
<xs:import namespace="http://io.java/xsd"/>
<xs:import namespace="http://text.lowagie.com/xsd"/>
<xs:import namespace="http://example.com/xsd"/>
<xs:element name="convert">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="html" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="convertResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax28:MergeXfdfToFormResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.com/xsd">
<xs:complexType name="MergeXfdfToFormResult">
<xs:sequence>
<xs:element minOccurs="0" name="errorMessage" nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="pdf" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="resultCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="convertRequest">
<wsdl:part name="parameters" element="ns:convert"/>
</wsdl:message>
<wsdl:message name="convertResponse">
<wsdl:part name="parameters" element="ns:convertResponse"/>
</wsdl:message>
<wsdl:portType name="ConvertionServiceServicePortType">
<wsdl:operation name="convert">
<wsdl:input message="ns:convertRequest" wsaw:Action="urn:convert"/>
<wsdl:output message="ns:convertResponse" wsaw:Action="urn:convertResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ConvertionServiceServiceSoap11Binding" type="ns:ConvertionServiceServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="convert">
<soap:operation soapAction="urn:convert" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ConvertionServiceService">
<wsdl:port name="ConvertionServiceServiceHttpSoap11Endpoint" binding="ns:ConvertionServiceServiceSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/ConvertionServiceService.ConvertionServiceServiceHttpSoap11Endpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

 

Hi,

 

I found only 2 messages regarding the above exception and none of them helped me.

Can anyone explain me when this happens?

 

I'm trying to connect to the attached WSDL with no success.

Any help will be appreciated.

Thanks,

Yishay

 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://example.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax24="http://text.lowagie.com/xsd" xmlns:ax21="http://io.java/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://example.com">
<wsdl:documentation>
Example
</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax28="http://example.com/xsd" xmlns:ax26="http://text.lowagie.com/xsd" xmlns:ax23="http://io.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.com">
<xs:import namespace="http://io.java/xsd"/>
<xs:import namespace="http://text.lowagie.com/xsd"/>
<xs:import namespace="http://example.com/xsd"/>
<xs:element name="convert">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="html" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="convertResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax28:MergeXfdfToFormResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://example.com/xsd">
<xs:complexType name="MergeXfdfToFormResult">
<xs:sequence>
<xs:element minOccurs="0" name="errorMessage" nillable="true" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="pdf" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="resultCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="convertRequest">
<wsdl:part name="parameters" element="ns:convert"/>
</wsdl:message>
<wsdl:message name="convertResponse">
<wsdl:part name="parameters" element="ns:convertResponse"/>
</wsdl:message>
<wsdl:portType name="ConvertionServiceServicePortType">
<wsdl:operation name="convert">
<wsdl:input message="ns:convertRequest" wsaw:Action="urn:convert"/>
<wsdl:output message="ns:convertResponse" wsaw:Action="urn:convertResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ConvertionServiceServiceSoap11Binding" type="ns:ConvertionServiceServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="convert">
<soap:operation soapAction="urn:convert" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ConvertionServiceService">
<wsdl:port name="ConvertionServiceServiceHttpSoap11Endpoint" binding="ns:ConvertionServiceServiceSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/ConvertionServiceService.ConvertionServiceServiceHttpSoap11Endpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

 

Howdy.

 

I'm trying to make a call to an external web service - the WSDL imports correctly, I'm able to actually invoke the port call, and the processing works on the remote side, but I get a Callout Exception thrown on the response envelope:

 

System.CalloutException: Web service callout failed: Failed to get next element
What I've found is that APEX is successfully getting back the entire envelope (APEX Logs) but something must have either got whacked during the WSDL import on the response class, or the web service is returning data in a format that WebServiceCallout.invoke just can't deal with.
Code for response class:
    public class deliveryActivitySinceResponse {
        public WS_CO.deliveryActivity deliveryActivity;
        private String[] deliveryActivity_type_info = new String[]{'deliveryActivity','http://<clientwebsite>.com','deliveryActivity','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://<clientwebsite>.com','false','false'};
        private String[] field_order_type_info = new String[]{'deliveryActivity'};
    }

 

SOAP response envelope:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:deliveryActivitySinceResponse xmlns:ns2="http://<clientname>.com">
<deliveryActivity nextSequence="465x">
<delivery {multiple attributes}>
<delivery {multiple attributes}>
<delivery {multiple attributes}>
<delivery {multiple attributes}>
<delivery {multiple attributes}>
</deliveryActivity>
</soap:Body>
</soap:Envelope>

 

It's definitely getting back - but my guess is that the callout method can't parse that XML right.  I've done countless other integrations like this, and the only thing I can see that's fundamentally different from the previous ones is that element heirarchy one more level deep (ns2 to deliveryActivitySinceResponse to deliveryActivity) - the other ones I've done don't go that one more level deep.
Thoughts?  Thanks in advance!
-Andy