You need to sign in to do that
Don't have an account?
S-Controls
Apex to external Web Service communication
Hi
I'm new to Apex development.
I'm trying to communicate from Apex to external Web Service.
I'm able to access the Web Service from some other Java client without any issues.
But while accessing the same Web Service from the Apex code, I'm getting the following error.
Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
And I verified the SOAP request and response messages , they look good.
Here I'm copying them
SOAP Request
-----------------------------------------------------------------------------------------------
POST http://localhost:8080/Axis/services/SecondServiceSOAP HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: localhost:8080
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 356
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:concatRequest xmlns:ns1="http://ttdev.com/ss">
<s1>abc</s1>
<s2>124</s2>
</ns1:concatRequest>
</soapenv:Body>
</soapenv:Envelope>
--------------------------------------------------------------------------------------------------------
SOAP Response
--------------------------------------------------------------------------------------------------------
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 22 Jan 2008 22:38:14 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<concatResponse xmlns="http://ttdev.com/ss">
<companyName xmlns="">abc124</companyName>
</concatResponse>
</soapenv:Body>
</soapenv:Envelope>
-----------------------------------------------------------------------------------------------------
I'm using Axis1.3 and Tomcat 5.5 on SalesForce 8.
The Apex version and the endpoint version are 11.1
Can you please help me in solving this issue at the earliest.
Thanks
Sarada
I'm new to Apex development.
I'm trying to communicate from Apex to external Web Service.
I'm able to access the Web Service from some other Java client without any issues.
But while accessing the same Web Service from the Apex code, I'm getting the following error.
Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
And I verified the SOAP request and response messages , they look good.
Here I'm copying them
SOAP Request
-----------------------------------------------------------------------------------------------
POST http://localhost:8080/Axis/services/SecondServiceSOAP HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: localhost:8080
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 356
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:concatRequest xmlns:ns1="http://ttdev.com/ss">
<s1>abc</s1>
<s2>124</s2>
</ns1:concatRequest>
</soapenv:Body>
</soapenv:Envelope>
--------------------------------------------------------------------------------------------------------
SOAP Response
--------------------------------------------------------------------------------------------------------
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 22 Jan 2008 22:38:14 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<concatResponse xmlns="http://ttdev.com/ss">
<companyName xmlns="">abc124</companyName>
</concatResponse>
</soapenv:Body>
</soapenv:Envelope>
-----------------------------------------------------------------------------------------------------
I'm using Axis1.3 and Tomcat 5.5 on SalesForce 8.
The Apex version and the endpoint version are 11.1
Can you please help me in solving this issue at the earliest.
Thanks
Sarada
> http://localhost:8080/Axis/services/SecondServiceSOAP
Your server should be accessable from salesforce.com.
Thanks for giving the clue.
I verified with the url http://ipaddressof my Machine:8080/Axis/services/SecondServiceSOAP
then its throwing
IO Exception : Read Timed Out
I increased the Read Time out for that Force.com project to 420 seconds, but still facing the same issue.
If you have any idea please let me know.
Thanks
Sarada
address is I can try to ping it from here.
I put some debug statements in the Apex code and ran it.
I could see the following information
Case1: If I gave localhost
--------------------------------------
12:14:28 DEBUG - 20080125195057.320:Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13: Created Web Service callout to endpoint: http://localhost:8080/Axis/services/SecondServiceSOAP 20080125195057.320:Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13: Sending callout request 20080125195057.320:Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13:
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><concatRequest xmlns="http://ttdev.com/ss"><s1>Fujitsu</s1><s2>Labs2222</s2></concatRequest></env:Body></env:Envelope>
20080125195057.320:Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13: Reading callout response 20080125195057.320:Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /Axis/services/SecondServiceSOAP was not found on this server.</p> </body></html>
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html' Class.sar.ttdevComSs.SecondServiceSOAP.concat: line 14, column 13 AnonymousBlock.sar: line 1, column 1 Class.sar.TestApex.getCompanyName: line 33, column 23
That means I'm able to send the request to SalesForce and getting the error Repsonse.
-------------------------------------------------------------------------------------------------------------
Case2: If I give my ip address instead of localhost
I'm not getting the response but instead of that getting the following message
0080125200414.415:AnonymousBlock.sar: line 1, column 1: returning String from method webService static String getCompanyName() in 10016 ms
If you get any idea please let me know,
Thanks
Sarada
What is the error that you are getting for case 2.
0080125200414.415:AnonymousBlock.sar: line 1, column 1: returning String from method webService static String getCompanyName() in 10016 ms
This does not looks like an error.
IO Exception: Read Timed out
In the debug statements showing the following message
20080125200414.415:AnonymousBlock.sar: line 1, column 1: returning String from method webService static String getCompanyName() in 10016 ms
Its taking long time 10016ms, may be that is why I'm getting Read Timed Out error
10016ms > 10 seconds.
I have changed the Read Time to 420sec while creating the Force.com project in the Eclipse.
Will it not effect the Read Time??
And I have one more question...
My Web Service is running at my server like http://myIpaddress:8080/Axis/Services/MySErvice
Is SFDC able to communicate my Web Service and get the data ??
Or else I have to make available the Web Serivce on any public IP to be accessible by SFDC??
Thanks
Sarada
not adjustable, it is 10 seconds
also
your webservice must be publicly available as it is accessed from our servers.
Brad
I'm still running into issues after I made available my web service on a public ip.
I'm getting the folowing error
Unable to parse callout response. Apex type not found for element: companyName
Any clues??
Thanks
Sarada
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://ttdev.com/ss"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SecondService" targetNamespace="http://ttdev.com/ss">
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:element name="concatRequest" type="tns:ConcatRequest"></xsd:element>
<xsd:element name="concatResponse" type="tns:ConcatResponse"></xsd:element>
<xsd:complexType name="ConcatRequest">
<xsd:sequence>
<xsd:element name="s1" type="xsd:string"></xsd:element>
<xsd:element name="s2" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ConcatResponse">
<xsd:sequence>
<xsd:element name="companyName" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
This is the part of the WSDL file from which I have generated the Apex code.
This will display the input and output SOAP request. Please post this XML. I will take a look.
BTW, which SOAP stack are you using on the server side?
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header />
<env:Body>
<concatRequest xmlns="http://ttdev.com/ss">
<s1>WebService</s1>
<s2>Test</s2>
</concatRequest>
</env:Body>
</env:Envelope>
20080205202346.833:Class.sar.ttdevComSsImpl.SecondServiceSOAP.concat: line 15, column 13: Reading callout response 20080205202346.833:Class.sar.ttdevComSsImpl.SecondServiceSOAP.concat: line 15, column 13:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<concatResponse xmlns="http://ttdev.com/ss"><companyName xmlns="">WebService Test</companyName>
</concatResponse>
</soapenv:Body>
</soapenv:Envelope>
20080205202346.833:AnonymousBlock.sar: line 1, column 1: returning String from method webService static String displayCompanyName() in 187 ms
I verified in the System log, the SOAP messages look good.
I didn't get your question about the SOAP stack...
Thanks
xml response sets no namespace for companyName. It should be qualified.
So instead of:
<concatResponse xmlns="http://ttdev.com/ss"><companyName xmlns="">WebService Test</companyName>
it should be:
<concatResponse xmlns="http://ttdev.com/ss"><companyName>WebService Test</companyName>
What server are you running, .Net, AXIS?
I'm using Axis1.3
Thanks
Sarada
And when I'm trying to call the WebSErvice using the Java client, I got the following SOAP request n REsponse messages
SOAP Request
----------------------
POST http://localhost:8080/Axis/services/SecondServiceSOAP HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: localhost:8080
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 356
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:concatRequest xmlns:ns1="http://ttdev.com/ss">
<s1>abc</s1>
<s2>124</s2>
</ns1:concatRequest>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response
-----------------------
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Tue, 05 Feb 2008 23:29:38 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<concatResponse xmlns="http://ttdev.com/ss">
<companyName xmlns="">abc124</companyName>
</concatResponse>
</soapenv:Body>
</soapenv:Envelope>
Here also it contains xmlns="" for companyName.
I added elementFormDefault="qualified" for schema.. but still facing the same problem..
Web service callout failed: Unable to parse callout response. Apex type not found for element =companyName
WSDL says it is elementFormDefault="qualified".
1. So either you change the wsdl to unqualified:
<xsd:schema targetNamespace="http://ttdev.com/ss" elementFormDefault="unqualified">
2. Change the server to be qualified. So that it match up with the wsdl.
There should be some AXIS setting that you can tweak to do this.
HTHs,
I am having similar problem when accessing strikeiron webservice. Since this thread was very helpful and is very close to my problem, I though I could post my issue here. Please help me and btw, am NEW to SFDC.
As said above, I am accessing strikeiron webservice and trying to show the output in a scontrol but I am getting an error saying
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://www.strikeiron.com=ServiceStatus
It is not the problem of time out.
It seems that either your server is nott started yet or there is no defination to handling the requested Company name attribute.