You need to sign in to do that
Don't have an account?
Bms270
SOAP Header Content to call third-party webservice
I am using a third-party webservice to get some data from the server and load the data to my page in salesforce. The third-party service needs authentication through SOAP header in each request, so I defined the SOAP header in the WSDL but dont know how I can include my custom Tokens in it. my custom tokens are:
<VendorToken xmlns="urn:commerce:vendor">
<VendorId xmlns="urn:commerce:vendor">xxxx</VendorId>
</VendorToken>
<AuthenticationToken xmlns="urn:commerce:authentication">
<Username xmlns="urn:commerce:authentication">xxxx</Username>
<Password xmlns="urn:commerce:authentication">yyyy</Password>
</AuthenticationToken>
I dont know if I have to define this in my wsdl document or I can set the content of the header from the apex class that is generated from the wsdl. I appreciate your help.
Thanks.
<VendorToken xmlns="urn:commerce:vendor">
<VendorId xmlns="urn:commerce:vendor">xxxx</VendorId>
</VendorToken>
<AuthenticationToken xmlns="urn:commerce:authentication">
<Username xmlns="urn:commerce:authentication">xxxx</Username>
<Password xmlns="urn:commerce:authentication">yyyy</Password>
</AuthenticationToken>
I dont know if I have to define this in my wsdl document or I can set the content of the header from the apex class that is generated from the wsdl. I appreciate your help.
Thanks.
In your generated class, do you see the inputHttpHeaders_x definition.
If yes, did you try something like :
This will probably not work 'as is' but it might get you started.
David
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.commerce.xxx.com">
<soapenv:Header>
<VendorToken xmlns="urn:commerce:vendor">
<VendorId xmlns="urn:commerce:vendor">xxx</VendorId>
</VendorToken>
<AuthenticationToken xmlns="urn:commerce:authentication">
<Username xmlns="urn:commerce:authentication">xxx</Username>
<Password xmlns="urn:commerce:authentication">yyy</Password>
</AuthenticationToken>
</soapenv:Header>
<soapenv:Body>
<web:echo/>
</soapenv:Body>
</soapenv:Envelope>
-------------------------------------------------------------------------------------------
webservice WSDL structure I have does not generate the tokens inside the header: (is there any way to generate those from wsdl?)
-------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://webservices.commerce.xxx.com" xmlns:tns="http://webservices.commerce.xxx.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservices.commerce.xxx.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="echo">
<xsd:complexType/>
</xsd:element>
<xsd:element name="echoResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
????<xsd:element name="auth" type="xsd:string">
????
????</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="echoResponse">
<wsdl:part name="parameters" element="tns:echoResponse"/>
</wsdl:message>
<wsdl:message name="echoRequest">
<wsdl:part name="parameters" element="tns:echo"/>
</wsdl:message>
<wsdl:message name="authHeader">
<wsdl:part name="request_header" element="tns:auth"/>
</wsdl:message>
<wsdl:portType name="EchoServicePortType">
<wsdl:operation name="echo">
<wsdl:input name="echoRequest" message="tns:echoRequest"/>
<wsdl:output name="echoResponse" message="tns:echoResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EchoServiceHttpBinding" type="tns:EchoServicePortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="echo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="echoRequest">
<wsdlsoap:header message="tns:authHeader" part="request_header" use="literal"/>
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="echoResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EchoService">
<wsdl:port name="EchoServiceHttpPort" binding="tns:EchoServiceHttpBinding">
<wsdlsoap:address location="https://ecommerce2.xxx.com/shop/services/echoservice"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
-----------------------------------------------------------------------
These headers need to be in the soap header part not in http header, so using "soap.inputHttpHeaders_x" doesn't work here. let me know if I am thinking wrong here. any suggestion? I really appreciate your help.
Thanks
Message Edited by Bms270 on 09-25-2008 08:30 AM
Message Edited by Bms270 on 09-25-2008 08:32 AM
I missed the 'soap' headers part ...
I wouldn't know the answer to that but I see that you've got another thread going on where part of the answer is already given.
http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=8053
I'll be watching it too.
David