I have the following message available in the WSDL:
<message name="checklookupRequest">
<part name="mobileNumber" type="xsd:string" />
<part name="userName" type="xsd:string" />
<part name="password" type="xsd:string" />
</message>
I have created the following request inside the body tag of coldfusion page:
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:p1 = "https://abcd/checkLookup.php?wsdl" >
<soap:Header>
</soap:Header>
<soap:Body>
<p1:checklookupRequest>
<phonenumber>4135671234</phonenumber>
<username>test</username>
<password>password</password>
</p1:checklookupRequest>
</soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>
My question is that, I am using username and password in the cfhttp tag as well. So, it seems like I am bound to send username and password as a part of message invocation and as a part of cfhttp requirements. Please correct me if I am wrong.
Thanks
P.S: I don't have any Web API documentation available for the Web Service I am using.
Related
I have a proxy service to expose a soap api on wso2 ei, and i need to update the namespace value of the soap response with my proxy service and return another namespace value.
I have tried with the enrich mediator as follows inside the outsequence.
<property name="namespace"
scope="default"
type="STRING"
value="http://tempuri-updated.org/"/>
<enrich>
<source clone="false" property="namespace" type="property"/>
<target xmlns:ser="http://services.samples"
xmlns:ns="http://org.apache.synapse/xsd"
xpath="namespace-uri($body/*)/text()"/>
</enrich>
I get this error.
ERROR - EnrichMediator Invalid Target object to be enrich.
my actual soap response is as follows
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>12</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
my expected output as follows
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AddResponse xmlns="http://tempuri-updated.org/">
<AddResult>12</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
All your feedbacks are welcome
This cannot be done with the enrich mediator. Because in the code related to enrich mediator target handling [1], the parsed result of an xpath expression should be one of SOAPHeaderImpl, OMElement, OMText or OMAttribute. Since namespace-uri() is just returning a string value, the target to be enriched is becoming invalid. As an alternative to this use case, we can do an XSLT transformation using the XSLT mediator. Following is a sample XSL style sheet I tried.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="#* | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}"
namespace="http://tempuri-updated.org/">
<xsl:apply-templates select="#* | node()"/>
</xsl:element>
</xsl:template>
We can refer this style sheet in the XSLT mediator before sending the response out from the EI. The new namespace will be added to the body.
Try this.
http://codertechblog.com/wso2-change-payload-soap-envelope-namespace/
<sequence name="seTestChangeNamespace" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
(...)
<enrich>
<source type="body"/>
<target type="property" property="INPUT_MESSAGE"/>
</enrich>
<enrich>
<source type="inline">
<myns:Envelope xmlns:myns="http://schemas.xmlsoap.org/soap/envelope/">
<myns:Body/>
</myns:Envelope>
</source>
<target type="envelope"/>
</enrich>
<enrich>
<source type="property" property="INPUT_MESSAGE"/>
<target type="body"/>
</enrich>
(...)
</sequence>
I'm trying to use the PullSubscription with the SubscrubeToAllFolders attribute as documented on the Microsoft Office Dev Center:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<s:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</s:Header>
<s:Body>
<m:Subscribe>
<m:PullSubscriptionRequest SubscribeToAllFolders="">
<t:FolderIds />
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
<t:Watermark />
<t:Timeout>1</t:Timeout>
</m:PullSubscriptionRequest>
</m:Subscribe>
</s:Body>
</s:Envelope>
However this will always return an ErrorInternalServerError with text An internal server error occurred. The operation failed. and no faultactor. I've tried this with and without the superfluous <t:FolderIds /> and <t:Watermark/> tags. With different timeouts and different contents of <t:EventTypes>.
But when I remove the SubscribeToAllFolders="" and add in the folders manually like:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<s:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</s:Header>
<s:Body>
<m:Subscribe>
<m:PullSubscriptionRequest>
<t:FolderIds>
<t:DistinguishedFolderId Id="inbox" />
</t:FolderIds>
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
<t:EventType>FreeBusyChangedEvent</t:EventType>
</t:EventTypes>
<t:Watermark />
<t:Timeout>10</t:Timeout>
</m:PullSubscriptionRequest>
</m:Subscribe>
</s:Body>
</s:Envelope>
I get the expected response.
Anyone had any problems with SubscribeToAllFolders before? Is there a way to get it working? I'm relatively new to EWS and SOAP so am I doing anything definitively stupid up my end? Thanks for any help.
Your request isn't formatted correctly eg it should look like
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013_SP1" />
</soap:Header>
<soap:Body>
<m:Subscribe>
<m:PullSubscriptionRequest SubscribeToAllFolders="true">
<t:EventTypes>
<t:EventType>CopiedEvent</t:EventType>
<t:EventType>CreatedEvent</t:EventType>
<t:EventType>DeletedEvent</t:EventType>
<t:EventType>ModifiedEvent</t:EventType>
<t:EventType>MovedEvent</t:EventType>
<t:EventType>NewMailEvent</t:EventType>
</t:EventTypes>
<t:Timeout>5</t:Timeout>
</m:PullSubscriptionRequest>
</m:Subscribe>
</soap:Body>
</soap:Envelope>
I'd suggest you look at using the EWSEditor https://ewseditor.codeplex.com/ to do some testing it will both let you test the operation and give you the SOAP used for each request and response.
I am following RegOnline's developer pages to set up an API call to our server. They offer various examples of how to handshake (PHP, C#, JS, SOAP), the last one has the poorest example of how to include an API token as part of a method call.
http://developer.regonline.com/authentication-basics/
I am trying to call their GetEvent method, and this call has to include an API token that I have generated. However, based on their SOAP example, I am left guessing as to how to include the value of token. The following is their example:
<s:complexType name="TokenHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="APIToken" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
The other examples on the page have full versions that show explicitly where you could hard code the token if you had to. I will admit my knowledge of SOAP is minimal currently so perhaps I'm missing something in this example.
Here is my attempt to call the method. It only spits out a page of their documentation and a 200 OK status, which is not right.
<cfset apiToken = "xxxxx" />
<cfset eventID = "xxxxxx" />
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetEvent xmlns="http://www.regonline.com/api">
<eventID>#eventID#</eventID>
</GetEvent>
</s:Body>
</s:Envelope>
<s:complexType name="TokenHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="APIToken" type="s:string">
#apiToken#
</s:element>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
</cfoutput>
</cfsavecontent>
<cfhttp url="https://www.regonline.com/api" method="get" result="theCFHTTP" redirect="true">
<cfhttpparam type="HEADER" name="Content-Type" value="text/xml; charset=utf-8">
<cfhttpparam type="HEADER" name="Accept" value="application/soap+xml, multipart/related, text/*">
<cfhttpparam type="HEADER" name="User-Agent" value="Axis/1.1">
<cfhttpparam type="HEADER" name="Cache-Control" value="no-cache">
<cfhttpparam type="HEADER" name="Pragma" value="no-cache">
<cfhttpparam type="HEADER" name="SOAPAction" value="https://www.regonline.com/api/default.asmx/GetEvent">
<cfhttpparam type="HEADER" name="Content-Length" value="#len(soapBody)#">
<cfhttpparam type="xml" name="body" value="#soapBody#">
</cfhttp>
<cfdump var="#theCFHTTP#">
Your SOAP request is in a wrong format. All of the SOAP request should be within the SOAP envelope. Here is the template created in SoapUI for the getEvent request.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://www.regonline.com/api">
<soapenv:Header>
<api:TokenHeader>
<!--Optional:-->
<api:APIToken>?</api:APIToken>
</api:TokenHeader>
</soapenv:Header>
<soapenv:Body>
<api:GetEvent>
<api:eventID>?</api:eventID>
</api:GetEvent>
</soapenv:Body>
</soapenv:Envelope>
For the call itself, you may need to try post over get, but I'm unsure about this. The one thing I think you might need to update is the SOAPAction. In my test call in SoapUI, the action in the header was http://www.regonline.com/api/GetEvent. Though it may work both ways.
That's sort of not what you want to do. With SOAP calls, you just follow the XML they provided in the documentation (https://www.regonline.com/api/default.asmx?op=GetEvent).
So in the particular case, you want to replace the CSSAVECONTENT variable soapBody to below:
<cfsavecontent variable="soapBody">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<TokenHeader xmlns="http://www.regonline.com/api">
<APIToken>#apiToken#</APIToken>
</TokenHeader>
</soap:Header>
<soap:Body>
<GetEvent xmlns="http://www.regonline.com/api">
<eventID>#eventID#</eventID>
</GetEvent>
</soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>
See what that returns for you.
I have to make a request to a web service, that uses Axis2, I'm too close to have it working but i keep getting error messages and i'm sure it is in the construction of my SOAP XML. This was the SOAP:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<RequestsoapHeader>
<spId>SPID</spId>
<spPassword>RandomPass</spPassword>
<timeStamp>20130115160251</timeStamp>
</RequestsoapHeader>
</soap:Header>
<soap:Body>
<operation>
<name>getSPToken</name>
<input>http://zzz.zzz.zzz.zzz/my/redirection/url/</input>
</operation>
</soap:Body>
</soap:Envelope>
UPDATE!!!! Now the soap is this:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<RequestsoapHeader>
<spId>SPID</spId>
<spPassword>RandomPass</spPassword>
<timeStamp>20130115160251</timeStamp>
</RequestsoapHeader>
</soap:Header>
<soap:Body>
<getSPTokenRequest>
<SPredirectURL>http://zzz.zzz.zzz.zzz/my/redirection/url/</SPredirectURL>
</getSPTokenRequest>
</soap:Body>
</soap:Envelope>
The part i can't fix is the Body, i tried to call the operation in different ways, for example instead of <operation> i used <operation name="getSPToken">, i also tried not using operation and created a tag with the name: <getSPToken>, but nothing works.
This is the WSDL part that describes the operation i'm trying to call in the Web Service:
<wsdl:operation name="getSPToken">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ServiceException">
<soap:fault name="ServiceException" use="literal"/>
</wsdl:fault>
<wsdl:fault name="PolicyException">
<soap:fault name="PolicyException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
UPDATE!!! This is the interface XML (part of the WSDL) that i didn't post before:
<wsdl:types>
<xsd:schema elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.csapi.org/schema/parlayx/sicoweb/v1_0/local">
<xsd:element name="getSPTokenRequest" type="osg_sicoweb_local_xsd:getSPTokenRequest"/>
<xsd:complexType name="getSPTokenRequest">
<xsd:sequence>
<xsd:element name="SPredirectURL"
type="xsd:string" maxOccurs="1" minOccurs="1">
<xsd:annotation>
<xsd:documentation></xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="getSPTokenResponse" type="osg_sicoweb_local_xsd:getSPTokenResponse"/>
<xsd:complexType name="getSPTokenResponse">
<xsd:sequence>
<xsd:element name="SPToken" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
And this is the response i was getting:
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Date: Tue, 15 Jan 2013 21:10:49 GMT
Connection: close
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault xmlns:axis2ns73="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>axis2ns73:Client</faultcode>
<faultstring>The endpoint reference (EPR) for the Operation not found is http://xxx.xxx.xxx.xxx:xxx/path/to/service/ and the WSA Action = </faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
UPDATE!!!! With the new changes, the response i'm getting is this one:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>org.apache.axis2.databinding.ADBException: Unexpected subelement getSPTokenRequest</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
The operation getSPToken receives one parameter called SPredirectURL, that contains a URL of redirection, please help.
Try one of the following as your body:
<soap:Body>
<SPredirectURL>http://zzz.zzz.zzz.zzz/my/redirection/url/</SPredirectURL>
</soap:Body>
<soap:Body>
<getSPTokenRequest xmlns="http://www.csapi.org/schema/parlayx/sicoweb/v1_0/local">
<SPredirectURL>http://zzz.zzz.zzz.zzz/my/redirection/url/</SPredirectURL>
</getSPTokenRequest>
</soap:Body>
Based on the WSDL snippet, the web service endpoint is using the document/literal convention for messages, but without the WSDL message declarations it is unclear whether the 'bare' (first example) or 'wrapped' (second example) version is expected. The post at this address (http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/) gives good insight into the various dialects described by WSDL.
UPDATE:
Based on the schema inside the wsdl:types section, the fully-qualified name for the element expected by the service (based on the declared targetNamespace attribute of the schema element) is http://www.csapi.org/schema/parlayx/sicoweb/v1_0/local{getSPTokenRequest}
One way of establishing that name (inline namespace declaration) is shown in the updated second body above.
Post back with the next iteration.
I am trying to create a web service that can be consumed with SOAP. I were exercising with normal webservices that returns any values, but know i want to check which elements in the SOAP:BODY are needed and return them with a response. I found the methods
GetSoapRequest()
and
AddSoapResponse()
in the livedoc from adobe, but don't understand how to use them.
I saw the explenation of a request and response on w3school.com
i tried to solve the Problem with the tags "cfsavecontent"
<cffunction
name="soap"
access="remote"
returntype="any"
output="false">
<cfsavecontent variable="soapMessage">
<?xml version="1.0">
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
</soap:Header>
<soap:Body>
<m:GetPriveResponse xmlns:m="namespace">
<m:Price>1.90</m:Price>
</m:GetPriceResponse>
</soap:Body>
</soap:Envelope>
</cfsavecontent>
but it only works, if the cffunction has returntype="any". The type "xml" occurs an error.
thx for helf
The easiest way to create a web service in CF, see
Creating components for web services http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13a13-7fe2.html
Publishing web services
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78b7.html
I just installed the soapUI eclipse addon and called the WSDL that includes an argument of a complexe type. After testing the methods of my web service with the addon, I got the SOAP-Message I was searching all the time. Maybe it will help anybody, i just where searching long time for this solution.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:com="http://components.conner.somebody">
<soapenv:Header/>
<soapenv:Body>
<com:echoAddress soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<input xsi:type="com:Address">
<City xsi:type="xsd:string">?</City>
<Country xsi:type="xsd:string">?</Country>
<State xsi:type="xsd:string">?</State>
<Street xsi:type="xsd:string">?</Street>
</input>
</com:echoAddress>
</soapenv:Body>
</soapenv:Envelope>
Here is the method of the coldfusion component that will be called
<cffunction
name="echoAddress"
returnType="address"
output="false"
access="remote">
<cfargument
name="input"
type="address">
<cfreturn #arguments.input#>
</cffunction>