How to handle SOAP response in FLEX 3 - apache-flex

SOAP Request<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:deleteDataView xmlns:ns2="http://ws.$$$$$.#####.####.com/">
<identifier>5</identifier>
</ns2:deleteDataView>
</S:Body>
</S:Envelope>
SOAP Response<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:deleteDataViewResponse xmlns:ns2="http://ws.$$$$$.#####.####.com/">
<return>ERROR: A bug has been encountered,please try later</return&gt
</ns2:deleteDataViewResponse>
</S:Body>
</S:Envelope>
I want to read SOAP response in flex,am some what new to FLEX,pls help,even good resources will work.

Handling SOAP Response
<mx:WebService
id="userRequest"
wsdl="http://www.gnpcb.org/esv/share/soap/index.php?wsdl">
<mx:operation name="doPassageQuery" resultFormat="object"
fault="mx.controls.Alert.show(event.fault.faultString)"
result="showResult(event)"/>
</mx:WebService>
In the above code you are accessing your SOAP WebService, now you have the resultFormat is an Object and the result function is showResult()
private function showResult(e:ResultEvent):void
{
trace(e.result);
}
Resources
http://www.flexlive.net/?p=79

Related

How can i change/edit SOAP response in ASMX

Im creating a soap web service for our client and I need to change the response from:
<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>
<send_messageResponse xmlns="send_message_response">
<message_response>
<message_id>2001</message_id>
<description>sent</description>
<status>sent</status>
</message_response>
</send_messageResponse>
</soap:Body>
</soap:Envelope>
to
<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>
<send_message_response xmlns="send_message_response">
<message_response>
<message_id>2001</message_id>
<description>sent</description>
<status>sent</status>
</message_response>
</send_messageResponse>
</soap:Body>
</soap:Envelope>
i've tried adding
[WebMethod]
[return: XmlElement("message_response")]
[SoapDocumentMethod("send_message", RequestNamespace = "urn", ResponseNamespace = "send_message_response", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
but still cant change the response. im also wondering if any have experience in creating the Outbound API of Oracle Field Service Cloud? Coz our client is oracle :)

Paypal ManagePendingTransactionStatus method returning error

I'm trying to cancel a pending transaction via PayPal's Classic API (SOAP) using the ManagePendingTransactionStatus method, but the response is always an internal error. I have already tried to change the Action, DetailLevel, Version, and I've used various (existing) TransactionIDs, but nothing worked.
Have someone passed through something alike? Is there some configuration I'm missing?
I'm using the sandbox environment, from my ASP.NET WebForms (framework version 4.5) app, within my localhost on Windows 7 x64. Here are the request content:
URL: https://api-3t.sandbox.paypal.com/2.0/
Request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ns="urn:ebay:api:PayPalAPI">
<soapenv:Header>
<ns:RequesterCredentials>
<ebl:Credentials>
<ebl:Username>correct.username</ebl:Username>
<ebl:Password>correct.password</ebl:Password>
<ebl:Signature>Correct.Signature</ebl:Signature>
</ebl:Credentials>
</ns:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<ns:ManagePendingTransactionStatusReq>
<ns:ManagePendingTransactionStatusRequest>
<ebl:Version>104.0</ebl:Version>
<ns:TransactionID>3B880366F0154954J</ns:TransactionID>
<ns:Action>Deny</ns:Action>
</ns:ManagePendingTransactionStatusRequest>
</ns:ManagePendingTransactionStatusReq>
</soapenv:Body>
</soapenv:Envelope>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"></Security>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username xsi:type="xs:string"></Username>
<Password xsi:type="xs:string"></Password>
<Signature xsi:type="xs:string"></Signature>
<Subject xsi:type="xs:string"></Subject>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<ManagePendingTransactionStatusResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2014-05-28T14:27:44Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">1c49de851e39e</CorrelationID>
<Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
<ShortMessage xsi:type="xs:string">Internal Error</ShortMessage>
<LongMessage xsi:type="xs:string">Internal Error</LongMessage>
<ErrorCode xsi:type="xs:token">10001</ErrorCode>
<SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
</Errors>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">104.0</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">10958405</Build>
<TransactionID xsi:type="xs:string">3B880366F0154954J</TransactionID>
<Status xsi:type="xs:string">The Status of the transaction after running the your action (accept/deny) is:Unable To Determine</Status>
</ManagePendingTransactionStatusResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
According to the documentation, The ManagePendingTransactionStatus API operation accepts or denys a pending transaction held by Fraud Management Filters. If it is pending for any other reason the operation will likely produce an error.

405 status code not returning the response properly

I have an http method fault that executes when an incorrect http method is sent in the request.
when I set the status code as 405 ,the request returns a 502 bad gateway .
my fault is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="invalid-htttp-method-fault">
<DisplayName>invalid htttp method fault</DisplayName>
<FaultRules/>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<Payload contentType="application/xml">
<Fault>
<Code>405</Code>
<Description>Method Not Allowed</Description>
</Fault>
</Payload>
<StatusCode>405</StatusCode>
<ReasonPhrase>Method Not Allowed</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
If I change
<StatusCode>405</StatusCode>
<ReasonPhrase>Method Not Allowed</ReasonPhrase>
to
<StatusCode>403</StatusCode>
<ReasonPhrase>Method Not Allowed</ReasonPhrase>
I can see the response payload is returned perfectly . when I use 405 the response returned is :
{"fault":{"faultstring":"Received 405 Response without Allow Header","detail":{"errorcode":"protocol.http.Response405WithoutAllowHeader"}}}
I was able to reproduce the exact issue that you are facing and by doing some more research I found that HTTP 405 response must include an Allow-Header
Try changing your fault policy by adding a header -
<Headers>
<Header name="Allow">YOUR ALLOWED METHODS LIST</Header>
</Headers>
By doing this you should no more be getting the 502 bad gateway and will get what you are expecting as a response.
I hope this helps.
Thanks!
Ah.... Interesting. Response 405 requires an Allow header per the HTTP spec (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). So, the Apigee error is telling you that you need to add an Allow header to your FaultResponse like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Fault-405">
<DisplayName>Fault 405</DisplayName>
<FaultRules/>
<Properties/>
<FaultResponse>
<Set>
<Headers>
<Header name="Allow">GET, PUT, POST, DELETE</Header>
</Headers>
<Payload contentType="text/plain">This wasn't supposed to happen</Payload>
<StatusCode>405</StatusCode>
<ReasonPhrase>405 Rules</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
So add the Allow verbs in the <Set> block and you should be cool.

How to add custom header to ASMX web service call using jquery?

I have a web service with the following contract:
POST /Service/service.asmx HTTP/1.1
Host: xxx.xxx.xxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "xxx.xxx.xxx/Service/Method"
<?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>
<Request xmlns="xxx.xxx.xxx/Service/">
<transactiontype>string</transactiontype>
<username>string</username>
<password>string</password>
</Request>
</soap:Header>
<soap:Body>
<Method xmlns="xxx.xxx.xxx/Service/">
<xml>xml</xml>
</Method>
</soap:Body>
</soap:Envelope>
And I am trying to call the service using jquery. This is my code:
$.ajax({
url: serverUrl + 'Method',
type: "POST",
dataType: "xml",
data: { xml: "xml" },
beforeSend: function (req) {
req.setRequestHeader('Header', '<Request xmlns="xxx.xxx.xxx/Service/">'
+'<transactiontype>4</transactiontype>'
+'<agencyName>name</agencyName>'
+'<username>user</username>'
+'<password>pass</password>'
+'</Request>');
},
success: function (data) {
alert(data.text);
},
error: function (request, status, errorThrown) {
alert(status);
}
});
However, the header content is not passed to the web service? How would I go about passing the header credentials to my web service call?
soap:Header is an XML element inside the XML/SOAP data "payload". This is different than an HTTP headers. In the contract, SOAPAction (along with Content-Length, etc) is an HTTP header.
XmlHttpRequest.setRequestHeader is used for specifying HTTP headers. It has nothing to do with anything inside the XML (directly).
The first answer at Simplest SOAP example should give an example of how to make a SOAP request. Note:
xmlhttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/GetQuote");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
...
var xml = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope...' + etc;
xmlhttp.send(xml)
It is the XML which contains soap:Envelope and the child elements soap:Header and soap:Body.
Happy coding.

How to get BinarySecurityToken into the wcf soap request

I need to sign my soap request to a 3rd party. The provided an example what the call should look like. And I am trying, rather unsuccessfully to make this call with wcf.
I need to make a wcf soap call where the header contains BinarySecurityToken, Signature, and SecurityTokenReference.
Here is the example they sent me (with some of the values omitted) I have a certificate for signing, but I cant for the life of me figure out how to make this work
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="SecurityToken-..omitted.." xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">..omitted..</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#Body">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>..omitted...</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
..omitted..
</ds:SignatureValue>
<ds:KeyInfo><wsse:SecurityTokenReference><wsse:Reference URI="#SecurityToken-..omitted.." ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soapenv:Header><soapenv:Body wsu:Id="Body"><in0 xmlns="http://test.3rdParty.com">123</in0></soapenv:Body></soapenv:Envelope>
We ended up with a hotfix from microsoft and few custom classes

Resources