How can i change/edit SOAP response in ASMX - asp.net

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 :)

Related

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.

How to Set up SOAP Request via ASP.NET to url as a service?

Have the following code in my Default.aspx file, located at http://localhost/idss/Default.aspx:
<%# Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
<title>Testing IDSS Return Values</title>
</head>
<body>
<%#
// how we do it
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("idss/requests/categoryList.xml"));
// create the request to your URL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/idss/Default.aspx");
// add the headers
// the SOAPACtion determines what action the web service should use
// YOU MUST KNOW THIS and SET IT HERE
request.Headers.Add("SOAPAction", "http://ws.idssasp.com/Members.asmx/GetCategoryList");
// set the request type
// we use utf-8 but set the content type here
request.ContentType = "text/xml;charset=\"utf-8\"";
request.Accept = "text/xml";
request.Method = "POST";
// add our body to the request
Stream stream = request.GetRequestStream();
doc.Save( stream );
stream.Close();
// get the response back
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
request.Write(response);
}//end using
%>
</body>
</html>
The xml file located at: http://localhost/idss/requests/categoryList.xml looks like this:
<?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>
<AuthorizeHeader xmlns="http://ws.idssasp.com/Members.asmx">
<UserName>MyUsername</UserName>
<Password>MyPassword</Password>
</AuthorizeHeader>
</soap:Header>
<soap:Body>
<GetCategoryList xmlns="http://ws.idssasp.com/Members.asmx" />
</soap:Body>
</soap:Envelope>
Where MyUsername and MyPassword is filled in with the correct username and password. The URL located here: http://ws.idssasp.com/members.asmx?op=GetCategoryList&pn=0 tells me that SOAP should send a request like this:
POST /members.asmx HTTP/1.1
Host: ws.idssasp.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://ws.idssasp.com/Members.asmx/GetCategoryList"
<?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>
<AuthorizeHeader xmlns="http://ws.idssasp.com/Members.asmx">
<UserName>string</UserName>
<Password>string</Password>
</AuthorizeHeader>
</soap:Header>
<soap:Body>
<GetCategoryList xmlns="http://ws.idssasp.com/Members.asmx" />
</soap:Body>
</soap:Envelope>
But when I browse to http://localhost/idss/Default.aspx I get an Internal Server Error (500). What exactly am I doing wrong here? Do I need to add namespaces? Or other References somewhere in the Default.aspx file? If so, which one's are needed? Also, am I pointing to the correct in (HttpWebRequest)WebRequest.Create("http://localhost/idss/Default.aspx");?
Am I doing this correctly? I just feel like something is missing here.

asp.net Web Service, a list containing a list

I have an asp.net web service (.asmx) running on our server, it basically returns a result object which contains a list of users. The structure looks like this:
<?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:Body>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
This works fine, but I would like to add a list to my clsUser class. So I would like to change it from this:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsUser
{
public string firstName;
public string lastName;
public int idNUmber
}
To this:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsUser
{
public string firstName;
public string lastName;
public int idNumber
public List<clsExtraData> extraDataList;
}
Where clsExtraData contains a few strings:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsExtraData
{
public string description;
public string data;
}
So I would expect my structure to look something like the following:
<?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:Body>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList>
<description>string</description>
<data>string</data>
</extraDataList>
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList>
<description>string</description>
<data>string</data>
</extraDataList>
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
But instead I get the following:
<?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:Body>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList xsi:nil="true" />
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList xsi:nil="true" />
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
Our web service users will design their clients around this web service structure, if it's showing up with the <extraDataList xsi:nil="true" /> how will they know what fields to expect in the extraDataList? How can I get my web service structure looking as expected?
if you post the WSDL im pretty sure there is a link explaining the values and fields in extraDataList

wsdl soap exception

Having trouble with soap exceptions.
I'm throwing soap exception in asp.net web service and have to somehow get that exception (in form of xml) to show in browser, like this:
SOAP 1.1
<?xml version="1.0" encoding="utf-8"?>
<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>
<soap:Fault><faultcode>soap:Client</faultcode>
<faultstring></faultstring>
<detail>
<Error>
<ErrorNumber>1</ErrorNumber>
<ErrorMessage>Error...</ErrorMessage>
</Error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Throwing exception from web service:
XmlDocument doc = new XmlDocument();
XmlNode detailNode = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
XmlElement details = doc.CreateElement("Error");
XmlElement detailchild1 = doc.CreateElement("ErrorNumber");
detailchild1.InnerText = "1";
XmlElement detailchild2 = doc.CreateElement("ErrorMessage");
detailchild2.InnerText = "Error...";
details.AppendChild(detailchild1);
details.AppendChild(detailchild2);
detailNode.AppendChild(details);
throw new SoapException("Fault", SoapException.ClientFaultCode, "", details);
If I test it with windows application that calls that service, I can catch exception and extract all details so it seems that everything works with creating xml and throwing exception.
But all I'm getting from browser is internal error 500, which is according to other answers I found normal behaviour. Can I somehow get that xml in browser instead of internal error 500, maybe by changing web.config, IIS settings...
shouldn't this
throw new SoapException("Fault", SoapException.ClientFaultCode, "", details);
be
throw new SoapException("Fault", SoapException.ClientFaultCode, "", detailNode);
?

How to handle SOAP response in FLEX 3

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

Resources