function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
suloxsulox 

Web service callout failed: WebService returned a SOAP Fault: Server was unable to read request.

I have a visual force page that is calling an external web service and whenever I invoke the method on the web service I get this error. I tested the web service outside of salesforce and it works fine. In addition I made a hello world method and it runs find in salesforce. It just whenever I try to run any other method that does more than a simple hello world I get this error. Any help would be greatly appreciated. 

 

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Server was unable to read request. ---> There is an error in XML document (1, 814). ---> Input string was not in a correct format. faultcode=soap:Client faultactor=

Best Answer chosen by Admin (Salesforce Developers) 
suloxsulox
I found the solution. It seems that if you have a web service with variables other than type of string you must assign a value to all of the non-string variables even if you are not using those variables. Otherwise you will receive this error.

All Answers

prabhutumprabhutum

sulox,

 

To help others identify the issue, paste some code snippet with the post.

suloxsulox

I have been doing some research and I have found that this may be a microsoft.net bug where they do not generate some optional xml components that SF is looking for. The site is using .net 2.0.

 

The link to the web service is http://api.qlocal.com/QBMSAPI/1.0/service.asmx

 

Here is the code to the controller class:

public class QBMSController {
    public PageReference step2() {
        return null;
    }
   
  
   
    public PageReference HelloWorld()
    {
    qbmsapi.QBMSAPISoap stub = new qbmsapi.QBMSAPISoap();
    stub.HelloWorld();
    return null;
    }
   
    public PageReference Charge()
    {
        qbmsapi.QBMSAPISoap stub = new qbmsapi.QBMSAPISoap();

        Qbmsapi.CredentialInfo Credentials = new Qbmsapi.CredentialInfo();
        Qbmsapi.CustomerCreditCardChargeRq request = new Qbmsapi.CustomerCreditCardChargeRq ();
       
        Credentials.UserName = 'qlocaladmin';
        Credentials.Password = 'admin';
        Credentials.SecurityToken = '12345';
       
        request.TransRequestID = '123';
        request.CreditCardNumber = '4111111111111111';
        request.ExpirationMonth = 12;
        request.ExpirationYear = 2009;
        request.IsCardPresent = false;
        request.Amount = 2500.23;
        request.NameOnCard = 'Matt Meyers';
        request.CreditCardAddress = '1234 some test street';
        request.CreditCardPostalCode = '78727';
       
        Qbmsapi.CustomerCreditCardChargeRs response = stub.ChargeCreditCard(Credentials,request);
       
        return null;
    }

 


}

 

 

here is the code to the visual force page

 

<apex:page controller="QBMSController">
    <apex:form >
        <apex:pageBlock title="Charge Credit Card">
        <apex:outputLabel value="Credit Card" />:
        <apex:inputText value="{!Test}" />
        <apex:facet name="footer">
        <apex:commandButton action="{!Charge}" value="Charge Card" id="theButton"/>
                           </apex:facet>
        </apex:pageBlock>
    </apex:form>
 </apex:page>

 

 

like I said previously is I change the button action to HelloWorld it works fine in SF. Also if you try to hit the web service from outside of SF all functions work fine.

suloxsulox
I found the solution. It seems that if you have a web service with variables other than type of string you must assign a value to all of the non-string variables even if you are not using those variables. Otherwise you will receive this error.
This was selected as the best answer