No package.xml not found despite it is presented - sfdc-metadata-api

I want to deploy an Apex class via REST API in a "single package" way. The deployment process begins and then fails with "No package.xml found" error. The manifest file is put directly in the root of the archive, however the API tells me that there is no manifest.
My request body looks in the following way
----------------------------BOUNDARY
Content-Disposition: form-data; name="entity_content"
Content-Type: application/json
{
"deployOptions": {
"allowMissingFiles": false,
"autoUpdatePackage": false,
"checkOnly": false,
"ignoreWarnings": false,
"performRetrieve": false,
"purgeOnDelete": false,
"rollbackOnError": true,
"runTests": [],
"singlePackage": true,
"testLevel": "NoTestRun"
}
}
----------------------------BOUNDARY
Content-Disposition: form-data; name="file"; filename="deploy.zip"
Content-Type: application/zip
UEsDBAoAAAAAAM4EL1Zi1oXYuQAAALkAAAALAAAAcGFja2FnZS54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCI/PjxQYWNrYWdlIHhtbG5zPSJodHRwOi8vc29hcC5zZm9yY2UuY29tLzIwMDYvMDQvbWV0YWRhdGEiPjx0eXBlcz48bWVtYmVycz5BPC9tZW1iZXJzPjxuYW1lPkFwZXhDbGFzczwvbmFtZT48L3R5cGVzPjx2ZXJzaW9uPjU2LjA8L3ZlcnNpb24+PC9QYWNrYWdlPlBLAwQKAAAAAADOBC9WAAAAAAAAAAAAAAAACAAAAGNsYXNzZXMvUEsDBAoAAAAAAM4EL1aRdfeXigAAAIoAAAAWAAAAY2xhc3Nlcy9BLmNscy1tZXRhLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04Ij8+PEFwZXhDbGFzcyB4bWxucz0iaHR0cDovL3NvYXAuc2ZvcmNlLmNvbS8yMDA2LzA0L21ldGFkYXRhIj48YXBpVmVyc2lvbj41Ni4wPC9hcGlWZXJzaW9uPjwvQXBleENsYXNzPlBLAwQKAAAAAADOBC9WnojzmRIAAAASAAAADQAAAGNsYXNzZXMvQS5jbHNwdWJsaWMgY2xhc3MgQSB7IH1QSwECFAAKAAAAAADOBC9WYtaF2LkAAAC5AAAACwAAAAAAAAAAAAAAAAAAAAAAcGFja2FnZS54bWxQSwECFAAKAAAAAADOBC9WAAAAAAAAAAAAAAAACAAAAAAAAAAAABAAAADiAAAAY2xhc3Nlcy9QSwECFAAKAAAAAADOBC9WkXX3l4oAAACKAAAAFgAAAAAAAAAAAAAAAAAIAQAAY2xhc3Nlcy9BLmNscy1tZXRhLnhtbFBLAQIUAAoAAAAAAM4EL1aeiPOZEgAAABIAAAANAAAAAAAAAAAAAAAAAMYBAABjbGFzc2VzL0EuY2xzUEsFBgAAAAAEAAQA7gAAAAMCAAAAAA==
----------------------------BOUNDARY--
where Base64-encoded Zip file has the following structure
package.xml
classes/
A.cls
A.cls-meta.xml
and those three files look in the following way.
(package.xml)
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>A</members>
<name>ApexClass</name>
</types>
<version>56.0</version>
</Package>
(A.cls)
public class A { }
(a.cls-meta.xml)
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
</ApexClass>
I've also tried to set singlePackage to false and use unpackaged folder as a wrapper but I doesn't work, too.
There is a possibility that "No package.xml found" is a catch-all error that makes solving the problem harder than it should be.

Related

Cors issues using sharepoint

i'm trying to query using REST API (sharepoint) and get some results.
this is where i've started
https://www.slideshare.net/CoreyRoth/fives-ways-to-query-share-point-2013-search-sharepoint-summit-toronto-2013, slide 31
this is what i have
document.getElementById("restApi")
.addEventListener("click", restApi, false);
function restApi() {
var queryUrl = "https://myAppDomain.org/_api/search/query?querytext='" + $("#restSearch").val() + "'";
$.ajax({
type: "GET",
url: queryUrl,
xhrFields: {
withCredentials: true
},
headers: {
"Accept": "application/json; odata=verbose"
},
success: function (data) {
var results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
},
error: function (error) {
}
});
}
this is the problem.
XMLHttpRequest cannot load "https://myAppDomain.org/_api/search/query?querytext=x" No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:63734' is therefore not allowed
access.
and another way i've tried providing password and username
headers: {
"Accept": "application/json; odata=verbose",
"password": "my password",
"username": "my account name"
},
for which i get
XMLHttpRequest cannot load
https://myAppDomain.org/_api/search/query?querytext=x. Response to
preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:63734' is therefore not allowed
access. The response had HTTP status code 401.
I'm using .net webApi, for which i've installed the cors packages, configuration
// Enabled cors
config.EnableCors(new EnableCorsAttribute("*", "*", "*") { SupportsCredentials = true });
The app are internal and i'm using windows credentials pass and account name.
So why am i getting this error, what do i do wrong?, i've searched and tried other solutions but always get the same problem related to
No 'Access-Control-Allow-Origin' header is present on the requested
Open IIS
Go to Sites and find your Sharepoint site
Right-click -> Explore
Open web.config
Add the following code inside system.webServer node
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Save and exit
I've managed to solve my issue (partially, because i would have wanted to use CSOM rather then REST API on client side) by allowing cross domain calls from my application, directly to the application(sharepoint app) for which i made the request.
So in the requested app i've added the following file :
web.config
in section :
system.webserver/httpprotocol/customheaders
content :
<add name="Access-Control-Allow-Origin" value="https://myApplicationDomain.zzz" />
<add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Credentials" value="true" />
If the server is being developed by you
Have you put the "Access-Control-Allow-Origin: localhost" in your .htaccess or in your webserver configuration?
You can, also, add that header in your response from the server.

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.

Accept UTF-8 encoded strings in ASP.NET WebService

I've got a ASP.NET WebService that looks something like this:
[WebMethod]
public static void DoSomethingWithStrings(string stringA, string stringB)
{
// and so on
}
An third party application should call this webservice. However this application encodes strings as UTF-8 and all umlauts are replaced by '??'. I can view the call and the special characters are formatted well:
<?xml version="1.0" encoding="utf-8" ?>
<!-- ... -->
<SoapCall>
<DoSomethingWithStrings>
<stringA>Ä - Ö - Ü</stringA>
<stringB>This is a test</stringB>
</DoSomethingWithStrings>
</SoapCall>
This produces the following output, when I simply print the strings inside the webservice method:
?? - ?? - ??
This is a test
How can I configure the WebService to accept UTF-8 encoded strings?
Update
Fiddler also tells me that the content-type charset of the http request is UTF-8.
Update 2
I tried to add following code to global.asax for debugging purposes:
public void Application_BeginRequest(object sender, EventArgs e)
{
using (var reader = new System.IO.StreamReader(Request.InputStream))
{
string str = reader.ReadToEnd();
}
}
This reads the actual SOAP call. The StreamReaders encoding is set to UTF-8. The SOAP call looks correct:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<DoSomethingWithStrings xmlns="http://www.tempuri.org/">
<stringA>Ä - Ö - Ü</stringA>
<stringB>This is a test!</stringB>
</DoSomethingWithStrings>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In the web.config file the globalization settings are set correctly:
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8" culture="de-DE" uiCulture="de-DE" />
So it looks like something that deserializes the SOAP message does not use UTF-8 but ASCII encoding.
Finally it turns out that something went wrong within accepting HTTP-Messages. I don't actually know what manipulates the HTTP-Request, but I found a workaround for this. Eventhough Fiddler showed me the correct content type (text/xml; charset=utf-8) in my Application_BeginRequest the Request.RequestContext.HttpContext.Request.ContentType was just text/xml, which lead to a fallback to default (ASCII) encoding within the ASMX serializer. I've added the following code to the Application_BeginRequest handler and everything works for now.
if (Request.RequestContext.HttpContext.Request.ContentType.Equals("text/xml"))
{
Request.RequestContext.HttpContext.Request.ContentType = "text/xml; charset=UTF-8";
}
Thanks for your help!
Try this:-
byte[] bytes=Encoding.UTF8.GetBytes(yourString);
NOTE:-
Strings never contain anything utf-* or anything else encoded
The SOAP call is being decoded as ASCII somewhere - each of the umlauts are 2 bytes with high bit being set, which turns into ?? when decoded as ASCII.
So, something like this is happening:
byte[] bytesSentFromClient = Encoding.UTF8.GetBytes("Ä - Ö - Ü");
string theStringIThenReceiveInMyMethod = Encoding.ASCII.GetString(bytesSentFromClient);
Console.WriteLine(theStringIThenReceiveInMyMethod);
//?? - ?? - ??
To verify this is happening for sure, you should compare stringA == "Ä - Ö - Ü" rather than printing it somewhere.
I guess you could start by doing a project-wide search for "ASCII" and then work from there if you find anything.
You could also try
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
Under the <system.web> tag in Web.config file.
I had the same problem. Asmx web service converted my UTF-8 to ASCII or, better to say to ??????. Your post helped me a lot.
The solution I found was to change version of SOAP protocol from 1.1 to 1.2
I mean:
POST /WebService1.asmx HTTP/1.1
Host: www.tempuri.org
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.tempuri.org/HelloWorld"
<?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>
<HelloWorld xmlns="http://www.tempuri.org/">
<inputParam>Привет</inputParam>
</HelloWorld>
</soap:Body>
</soap:Envelope>
had the problem. But when I changed my request to SOAP 1.2:
POST /WebService1.asmx HTTP/1.1
Host: www.tempuri.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloWorld xmlns="http://www.tempuri.org/">
<inputParam>Привет</inputParam>
</HelloWorld>
</soap12:Body>
</soap12:Envelope>
The issue was solved.

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.

IDataServiceMetadataProvider - Entities dont show up in $metadata

I am trying to write our own RIA services provider to expose data from a server that I access via ODBC. I follow th eguidelines set out at http://blogs.msdn.com/alexj/archive/2010/03/02/creating-a-data-service-provider-part-9-un-typed.aspx
I have written our own IDataServiceMetadataProvider / IDataServiceQueryProvider pair and get no errors on what i do.
I am putting in a resource set like this:
ResourceType tableType = new ResourceType(
typeof(Dictionary<string, object>),
ResourceTypeKind.EntityType,
null,
"Martini",
table_name,
false
);
tableType.CanReflectOnInstanceType = false;
var prodKey = new ResourceProperty(
"Key",
ResourcePropertyKind.Key |
ResourcePropertyKind.Primitive,
ResourceType.GetPrimitiveResourceType(typeof(int))
);
prodKey.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodKey);
var prodName = new ResourceProperty(
"Name",
ResourcePropertyKind.Primitive,
ResourceType.GetPrimitiveResourceType(typeof(string))
);
prodName.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodName);
_MetaDataProvider.AddResourceType(tableType);
_MetaDataProvider.AddResourceSet(new ResourceSet(table_name, tableType));
I see the requests coming in for enumerating the resource sets. I check them there in a breakpoint, and the resource set and the type is there, with all properties.
Still, the output I get is:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <service xml:base="http://localhost:2377/MartiniData.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
- <workspace>
<atom:title>Default</atom:title>
</workspace>
</service>
And for the $metadata version:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
- <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
- <Schema Namespace="Martini" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm">
<EntityContainer Name="Martini" m:IsDefaultEntityContainer="true" />
</Schema>
</edmx:DataServices>
</edmx:Edmx>
The actual metadata for the types never shows up, no error is shown. pretty frustrating. Anyone any idea?
Hmpf. Found.
config.SetEntitySetAccessRule("*", EntitySetRights.All);
was missing in the initialization, so all entities were filtered out ;)

Resources