How to call processing page via web service - web-services

I have a processing page and I want to run function process all via web service (add web reference into my C# window form app). My code below:
var context = new ModuleABCService.Screen() // limk web services: http://localhost:8686/soap/DMSBL009.asmx
{
CookieContainer = new CookieContainer(),
AllowAutoRedirect = true,
EnableDecompression = true,
Timeout = 60000
};
var loginResult = context.Login(string.Format("{0}#{1}", val.UserName, company), val.Password);
if (loginResult.Code != ErrorCode.OK)
{
throw new Exception(string.Format("Can not login {0}", company));
}
Content content = context.GetSchema();
context.Clear();
context.Submit(
new Command[]
{
content.Actions.ProcessAll
}
);
And I got an exception message:
System.Web.Services.Protocols.SoapExceptio:n Server was unable to process request. ---> PX.Data.PXUndefinedCompanyException: Unable determine proper company id for the request. at PX.Data.PXDatabaseProviderBase.getCompanyID(String tableName, companySetting& setting) in c:\Builders\4_10-2014_4_28-21_21_17-Full\Scripts\BuildTemp\NetTools\PX.Data\Database\Common\DbProviderBaseCompanies.cs:line 471...
Have you ever got this error before? Could you please give me any suggestion? Thank you so much!

Ok, I found out, because Acumatica's license

Related

Error when accessing ESB Proxy with Jaggery WSStub

I created a web service and was able to send requests to it from a serverside Jaggery.js script with no problem. Then I created a WSDL Proxy Service inside WSO2 ESB and tested it using the "Try it!" feature.
After I redirected my serverside script from the original web service to its proxy inside ESB, I got the error in System Logs:
The endpoint reference (EPR) for the Operation not found is /services/BpmAdderProcessProxy.BpmAdderProcessProxyHttpSoap11Endpoint and the WSA Action = urn:anonOutInOpResponse. If this EPR was previously reachable, please contact the server administrator.
To see in detail what was happening I activated the "SOAP Message Tracer" of the ESB. Suddenly my serverside script could access the webservice via my ESB proxy. Then I deactivated the "SOAP Message Tracer" and the error message was back again. Is my serverside script correct? Or does the debugging tool modify behavior of debugged code?
I'm a JavaScript developer. Actually Jaggery and UES are targeted at people like me. I'm not supposed to look inside Java code, am I? Is there a forum where JavaScript developers discuss WSO2 UES and Jaggery?
My serverside code is as follows:
<%
var x = request.getParameter("x");
var y = request.getParameter("y");
//var sum = parseInt(x) + parseInt(y);
var sum = add(parseInt(x), parseInt(y));
response.content = {
success: true,
data: {
result: sum
}
};
function add(x, y) {
var ws = require('ws');
var stub = new ws.WSStub("http://02-128:8280/services/BpmAdderProcessProxy?wsdl");
var process = stub.services["BpmAdderProcessProxy"].operations["process"];
var payloadTemplate = process.payloadXML();
var payload = replaceQuestionMarks(payloadTemplate, arguments);
var resultXml = process.request(payload);
var resultValue = resultXml.children().text();
return parseInt(resultValue);
}
function replaceQuestionMarks(template, values) {
var i = 0;
return template.replace(
/\?/g,
function() {
return values[i++];
}
);
}
%>
In ESB v4.8.1, pass-through transport is enabled by default and it does not support SOAP body based dispatching (it does not build the message so it can't acces the body's first element to find the operation)
You can append the operation name to the endpoint url : http://host:8280/services/BpmAdderProcessProxy/OperationName
You can add this parameter in your proxy conf (BpmAdderProcessProxy) in WSO2 ESB : <parameter name="disableOperationValidation" locked="false">true</parameter>
You can edit wso2esb/repository/conf/axis2/axis2.xml and replace <handler class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>
with
<handler class="org.apache.synapse.core.axis2.SynapseSOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>

why NotFound error occur in REST services with windows Phone app?

i tried to connect REST web servie from windows phone 8 application.
it was working proberly for weeks but after no change in it I get this generic error :
System.Net.WebException: The remote server returned an error:
NotFound.
i tried to test it by online REST Clients and services works properly
i tried to handle Exception and parse it as webException by this code :
var we = ex.InnerException as WebException;
if (we != null)
{
var resp = we.Response as HttpWebResponse;
response.StatusCode = resp.StatusCode;
and i get no more information and final response code is : "NotFound"
any one have any idea about what may cause this error?
there is already a trusted Certificate implemented on the server . the one who has the server suggested to have a DNS entry for the server, this entry should be at the customer DNS or in the phone hosts file .that what i done and worked for awhile but now it doesn't work however i checked that there is no thing changed
this is sample for Get Request it works proberly on Windwos Store apps :
async Task<object> GetHttps(string uri, string parRequest, Type returnType, params string[] parameters)
{
try
{
string strRequest = ConstructRequest(parRequest, parameters);
string encodedRequest = HttpUtility.UrlEncode(strRequest);
string requestURL = BackEndURL + uri + encodedRequest;
HttpWebRequest request = HttpWebRequest.Create(new Uri(requestURL, UriKind.Absolute)) as HttpWebRequest;
request.Headers["applicationName"] = AppName;
request.Headers["applicationPassword"] = AppPassword;
if (AppVersion > 1)
request.Headers["applicationVersion"] = AppVersion.ToString();
request.Method = "GET";
request.CookieContainer = cookieContainer;
var factory = new TaskFactory();
var getResponseTask = factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
HttpWebResponse response = await getResponseTask as HttpWebResponse;
// string s = response.GetResponseStream().ToString();
if (response.StatusCode == HttpStatusCode.OK)
{
XmlSerializer serializer = new XmlSerializer(returnType);
object obj = serializer.Deserialize(response.GetResponseStream());
return obj;
}
else
{
var Instance = Activator.CreateInstance(returnType);
(Instance as ResponseBase).NetworkError = true;
(Instance as ResponseBase).StatusCode = response.StatusCode;
return Instance;
}
}
catch (Exception ex)
{
return HandleException(ex, returnType);
}
}
i tried to monitor connections from Emulator and i found this error in connection :
**
Authentication failed because the remote party has closed the
transport stream.
**
You saw the client implement a server side certificate in the service. Did you have that certificate installed on the phone? That can be the cause of the NotFound error. Please, can you try to navigate to the service in the phone or emulator internet explorer prior to testing the app? If you do that, you can see the service working in the emulator/phone internet explorer? Maybe at that point internet explorer ask you about installing the certificate and then you can open your app, and it works.
Also remember if you are testing this in the emulator, every time you close it, the state is lost so you need to repeat the operation of installing the certificate again.
Hope this helps.
If you plan to use SSL in production in general public application (not company-distribution app), you need to ensure your certificate has one of the following root authorities:
SSL root certificates for Windows Phone OS 7.1.
When we had same issue, we purchased SSL certificate from one of those providers and after installing it on server we were able to make HTTPS requests to our services with no problem.
If you have company-distribution app, you can use any certificate from company's Root CA.

Copy Web Service in SharePoint for Office 365

I am trying to upload files greater than 100 MB size to SharePoint Portal for Office 365. I have tried three different ways to achieve the same.
Copy Web Service, along with the httpRuntime Setting in place with maxRequestLength set as 2097151 and executionTimeout as 14400. Also, I did try setting the Timeout as "Infinite" and "60000".
Error: The underlying connection was closed: An unexpected error occurred on a send.
Web Client, using UploadDataAsync method to "PUT" the file bytes to the destination Url. Even with this, the httpRuntime setting was in place as above.
Error: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
HttpWebRequest, with ServicePointManager.Expect100Continue set to false. Also tried the same with SendChunked as both true and false.
Error: The request was aborted: The request was canceled.
Apart from all these, I have also added
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
return webRequest;
}
in the proxy class generated for Copy service. The limitation is I can't use CSOM to upload the files.
And still the Upload request times out every time. Any help would be very much appreciated.
Thanks in advance.
Try using the following piece of code :-
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest request = (HttpWebRequest)webRequest;
request.CookieContainer = CookieContainer;
request.Method = "PUT";
request.KeepAlive = true;
request.Timeout = Timeout.Infinite;
byte[] buffer = new byte[1024];
using (Stream stream = request.GetRequestStream())
{
using (MemoryStream memoryStream = new MemoryStream(fileBytes))
{
memoryStream.Seek(0, SeekOrigin.Begin);
for (int i = memoryStream.Read(buffer, 0, buffer.Length); i > 0;
i = memoryStream.Read(buffer, 0, buffer.Length))
{
stream.Write(buffer, 0, i);
}
}
}
WebResponse response = request.GetResponse();
response.Close();
Have you tried to change the default maximum upload file size?
What version of SharePoint are you using?

How to retrieve request info by request id?

When I invite my friends I get back request_ids. After that I proceed those ids to get info about users invites have been sent to and create records in my database based on user's public profile info. But when I try to get request info by request id I get error message saying "Unsupported get request" nevertheless access token is fine.
// create data object to be sent to FB API
var data = new Object();
data.method = 'apprequests';
data.message = MESSAGE_TEXT;
data.display = 'iframe';
data.access_token = ACCESS_TOKEN;
data.show_error = 'Yes';
data.title = TITLE_TEXT;
// call FB API
FB.ui(data, function(aResponse)
{
var request_ids = '';
if (aResponse && aResponse.request_ids)
request_ids = aResponse.request_ids.join(',');
if (request_ids)
{
// send request_ids string to my server for further processing
}
});
Example of such broken request id: 1930910810837. Trying to get info for it like this:
https://graph.facebook.com/1930910810837?access_token=ACCESS_TOKEN
Please help me understand what is wrong. May it be issue on Facebook side, for example, Facebook returned broken id for some reason? Thank you!!!

JavaFX applet communicating with server

I want to write some page with JavaFX applet. I want content on the applet to be dependent on user logged in.
I know I can call web services from JFX, but then what about login and session? Besides I think there might exist some better solutions for such communication than calling from applet a web service sitting on the machine applet comes from.
How can I do it?
You can build a servlet which returns the name of the logged in user.
Then in javafx you can use the class javafx.io.http.HttpRequest to call the servlet and read out the username. (The API also has some examples of how to use the HttpRequest)
The following javafx code prints out the return string of a Servlet:
var response: String;
def myRequest: HttpRequest = HttpRequest {
location: "http://localhost:8080/demo/foo.do";
method: HttpRequest.GET;
onInput: function(is: java.io.InputStream) {
var buff: StringBuffer = new StringBuffer();
var reader: BufferedReader
= new BufferedReader(new InputStreamReader(is));
var data: String;
while ((data = reader.readLine()) != null) {
buff.append(data);
}
response = buff.toString();
reader.close();
println(response);
}
};
myRequest.start();
EDIT: You should also take a look at this article: http://blogs.oracle.com/warren/entry/authenticating_a_javafx_application_using which shows how to access the html document and cookies from within the applet which resides on the document. That should be a very interesting approach for authentication.