Task: Trying to upgrade from minio.netcore 1.1.1 client to minio client 3.1.13
Problem: When i try to create a bucket with the new client I get the following excpetion thrown:
MinIO API responded with message=The XML you provided was not well-formed or
did not validate against our published schema
I've tested in isolation from the rest of my code and can't see what the issue is:
using System;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = new Minio.MinioClient("{serverIpAddress}:9000", "myaccesskey", "mysecretkey");
var bucketid = Guid.NewGuid().ToString();
await client.MakeBucketAsync(bucketid,"uk-st-1");
var result = await client.BucketExistsAsync(bucketid);
}
}
}
and my csproj is switching between these 2 nugets:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Minio" Version="3.1.13" />
<!--<PackageReference Include="Minio.NetCore" Version="1.1.1" />-->
</ItemGroup>
</Project>
I've tried catching the traffic and the XML it produces for both nugets is this:
<?xml version="1.0" encoding="utf-8"?>
<q1:CreateBucketConfiguration xmlns:q1="http://s3.amazonaws.com/doc/2006-03-01/">
<q1:LocationConstraint>uk-st-1</q1:LocationConstraint>
</q1:CreateBucketConfiguration>
Related
I have a below xsd file in a jar dependency file in a Spring boot project. The xsd does not declare the element declaration, which is required by spring boot validation. So I am trying to add another xsd in my project resource folder to declare element type.
XSD in Jar file: /wsdl/xsd/UserService-v1-0.xsd
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema targetNamespace="http://usermanagement.com/userservice/xsd/2014/07"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:userservice="http://usermanagement.com/userservice/xsd/2014/07"
elementFormDefault="qualified">
<xsd:import namespace="http://usermanagement.com/userservice/common/xsd/2014/09" schemaLocation="userserviceCommon-v1-0.xsd"/>
<xsd:import namespace="http://usermanagement.com/userserviceabsolute/common/xsd/2014/09" schemaLocation="userserviceAbsoluteCommon-v1-0.xsd"/>
<xsd:complexType name="GetUsersRequest">
<xsd:attribute name="language" type="xsd:language" use="optional" default="en" />
</xsd:complexType>
</xsd:schema>
Please note that I tried to keep the complex type simple by removing some of the elements for this post. The location of file is /wsdl/xsd.
XSD to declare the element in the main Project resource: /wsdl/xsd/UserService-type-v1-0.xsd
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema targetNamespace="http://usermanagement.com/userservice/wsdl/userserviceService-v1-0"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:userservice="http://usermanagement.com/userservice/xsd/2014/07"
elementFormDefault="qualified">
<import namespace="http://usermanagement.com/userservice/xsd/2014/07" schemaLocation="jar:file://{path to the jar}/!/wsdl/xsd/userserviceService-v1-0.xsd"/>
<element name="GetUsersRequest" type="userservice:GetUsersRequest"/>
</xsd:schema>
As per my understanding we need to refer to the schemaLocation of xsd file in jar using notation "jar:file://{path to the jar}/!/wsdl/xsd/userserviceService-v1-0.xsd".
However I am not sure how to declare the path to the jar. Also not sure if this is the only way to refer to the definitions in the xsd in the jar files. In the above approach when ever a new version of jar is released we need to update the xsd file.
Also including the Spring WS schema validation config:
#Configuration
public class MyWsValidatorConfig extends WsConfigurerAdapter {
#Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor();
validatingInterceptor.setValidateRequest(true);
validatingInterceptor.setValidateResponse(true);
validatingInterceptor.setXsdSchemaCollection(new XsdSchemaCollection() {
#Override
public XsdSchema[] getXsdSchemas() {
return null;
}
#Override
public XmlValidator createValidator() {
try {
return XmlValidatorFactory.createValidator(getSchemas(), "http://www.w3.org/2001/XMLSchema");
} catch (Exception e) {
log.error("Failed to create validator e={}", e);
}
return null;
}
public Resource[] getSchemas() {
List<Resource> schemaResources = new ArrayList<>();
schemaResources.add(new ClassPathResource("/wsdl/xsd/UserService-v1-0.xsd"));
schemaResources.add(new ClassPathResource("/wsdl/xsd/UserService-type-v1-0.xsd"));
return schemaResources.toArray(new Resource[schemaResources.size()]);
}
});
interceptors.add(validatingInterceptor);
}
}
This is the first time I am working with XSD and SOAP web services. Able to cross other hurdles but got stuck with this issue.
Please help.
I created this small application. I build the application and can see the icon on the emulator when I clicked the icon, the page opens without showing anything and then it closes again without showing any error. I cancelled the build and then it shows the below message in the output window:
C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.0\zipalign.exe 4 "C:\VisualStudioMobileApplication\App3\App3\App3.Android\bin\Debug\com.companyname.app-Signed-Unaligned.apk" "bin\Debug\\com.companyname.app-Signed.apk"
1>Done building project "App3.Android.csproj" -- FAILED.
1>Build FAILED.
1>
1>Deploy failed on VisualStudio_android-23_arm_phone
1>Process was cancelled
Build has been canceled.
It does not give any error. I also put the break point on "OnCreate" method in MainActivity.cs file.The code does not break on that breakpoint even when I click on App3 icon.Below is my code for MainActivity.cs
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App3.Droid
{
[Activity(Label = "App3", Icon = "#drawable/icon", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.FormsMaps.Init(this, bundle);
LoadApplication(new App());
}
}
}
The code on MainPage.xaml is below:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App3"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="App3.MainPage">
<StackLayout VerticalOptions="StartAndExpand" Padding="30">
<maps:Map WidthRequest="960" HeightRequest="700"
x:Name="MyMap"
IsShowingUser="True"
MapType="Street"
/>
</StackLayout>
</ContentPage>
The code in MainPage.xaml.cs is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
namespace App3
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
MyMap.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(37, -122), Distance.FromMiles(1)));
}
}
}
I am using Visual studio 2017 enterprise version 15.6. The build of the entire project is always successful.
Below are my androidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.app" android:installLocation="auto">
<uses-sdk android:targetSdkVersion="27" />
<application android:label="app3.android">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyD1K1njDAN0"/>
</application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
I really need help to display the map when I click on App3. Any help will be highly appreciated.
On Windows, if you're using Hyper-V for your emulator, you can try this:
Start Hyper V manager
Select your machine under 'Hyper-V Manager'
Under Virtual Machines, right click on the VS emulator you are
trying to run your app on, select Settings.
Expand the 'Processor' node, select Compatibility.
Check the 'Migrate to a physical
computer with a different processor version' box, click OK and try
running your app again.
Hope it helps. Cheers!
Hoping someone can provide me with some guidance on an issue I'm facing using MEF with my VS2015 extension. I'm attempting to extend the IntelliSense capabilities of VS and followed this tutorial as a basis: https://msdn.microsoft.com/en-us/library/ee372314.aspx
Here is my ICompletionSourceProvider:
[Export(typeof(ICompletionSourceProvider))]
[Name("Test Statement Completion Provider")]
[Order(Before = "default")]
[ContentType("text")]
internal class MyCompletionSourceProvider : ICompletionSourceProvider
{
[Import]
internal ITextStructureNavigatorSelectorService NavigatorService { get; set; }
[Import]
internal IServiceProvider ServiceProvider { get; set; }
public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
{
return new MyCompletionSource(this, textBuffer);
}
}
The strange thing here is that this works fine on my machine (where this code was initially developed on), but fails to work on every other machine I've tried (both in Debug and Release). Breakpoints placed within TryCreateCompletionSource are never hit. I suspected this MEF component was never being exported, so I downloaded the mefx tool as recommend on MSDN and executed it on my generated DLL and received the following:
[Primary Rejection]
[Export] MyVSIX.Source.MyCompletionSourceProvider (ContractName="Microsoft.VisualStudio.Language.Intellisense.ICompletionSourceProvider")
[Import] MyVSIX.Source.MyCompletionSourceProvider.NavigatorService (ContractName="Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService")
[Exception] System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint:
ContractName Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService
RequiredTypeIdentity Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at Microsoft.ComponentModel.Composition.Diagnostics.CompositionInfo.AnalyzeImportDefinition(ExportProvider host, IEnumerable`1 availableParts, ImportDefinition id)
[Import] MyVSIX.Source.MyCompletionSourceProvider.ServiceProvider (ContractName="System.IServiceProvider")
[Exception] System.ComponentModel.Composition.ImportCardinalityMismatchException: No exports were found that match the constraint:
ContractName System.IServiceProvider
RequiredTypeIdentity System.IServiceProvider
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at Microsoft.ComponentModel.Composition.Diagnostics.CompositionInfo.AnalyzeImportDefinition(ExportProvider host, IEnumerable`1 availableParts, ImportDefinition id)
If I remove the [Import] statements these are all resolved and things begin working again. From the tutorial though, this seems as though it should just work. This also doesn't explain why it works 100% of the time on my machine and never works on any other machines.
This is my .vsixmanifest file:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="MyVSIX.Company.39048217-955a-4402-84e9-8a24f0730e72" Version="1.0" Language="en-US" Publisher="MyVSIX" />
<DisplayName>MyVSIX</DisplayName>
<Description xml:space="preserve"></Description>
<Icon>Resources\MyVSIX.ico</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0]" />
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
<Dependency Id="Microsoft.VisualStudio.MPF.14.0" DisplayName="Visual Studio MPF 14.0" d:Source="Installed" Version="[14.0]" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%|" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" Path="Output\ItemTemplates" />
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" Path="Output\ProjectTemplates" />
</Assets>
</PackageManifest>
Figured out why it wasn't working on other machines, but I still cannot understand why it was ever working on my machine. I changed this:
[Import]
internal IServiceProvider ServiceProvider { get; set; }
to this:
[Import(typeof(SVsServiceProvider)]
internal IServiceProvider ServiceProvider { get; set; }
Hope this helps someone in the future - I spent 2 days figuring this out!
I'm trying to access some images that I have saved in my Servlet inside the src/main/webapp/WEB-INF/imgs folder, this way:
link
I tryed to access these images with this code within the doPost method of my Servlet:
InputStream s = this.getClass().getClassLoader().getResourceAsStream("http://cardimgs.org/imgs/cardbackground1.jpg");
Movie movie = new Movie();
try {
byte[] bytes = IOUtils.toByteArray(s);
movie.setImage(bytes);
} catch (IOException e) {
e.printStackTrace();
}
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
// Store the image in App Engine's datastore
pm.makePersistent(movie);
} finally {
pm.close();
}
Movie class:
link 2,
the reason why I used the specified urlto create the InputStream is because in my appengine-web.xml I have:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myApplicationId</application>
<version>1</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
</system-properties>
<static-files>
<include path="/**.jpg"/>
<include path="/imgs" >
<http-header name="Access-Control-Allow-Origin" value="http://cardimgs.org" />
</include>
</static-files>
</appengine-web-app>
where I try to define my static files.
My problem is, though, that with the above code I can't access my file and fill the InputStream, which appears to be null, therefore returning a NullPointerException.
How can I successfully access my static files?
ClassLoader.getResourceAsStream() loads resources using *the class loader**. It thus looks for them in the classpath. The classpath of a web-app is constitued from WEB-INF/classes and from all the jars inside WEB-INF/lib. The path it expects looks like com/mycompany/myproject/somefile.txt. It can't be a HTTP URL.
What you need is ServletContext.getResourceAsStream("/WEB-INF/imgs/cardbackground1.jpg"). This method loads a resource from anywhere inside the web-app.
I am trying to validate a SOAP response message against the WSDL and I'm following the sample given in this question. However, I get the exception below.
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'SOAP-ENC:Array' to a(n) 'type definition' component.
I've seen a question about a similar error but I'm not sure if this is the same issue. I also don't understand why SOAP-ENC:Array is considered non-standard in that question when it appears in the SOAP spec.
Here is my validation code. The exception is raised on the Schema schema = schemaFactory.newSchema(schemas) line.
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document wsdlDoc = db.newDocument();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source wsdlSource = new StreamSource(new File("d:\\temp\\demo.wsdl"));
transformer.transform(wsdlSource, new DOMResult(wsdlDoc));
NodeList schemaNodes = wsdlDoc.getElementsByTagNameNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema");
int nrSchemas = schemaNodes.getLength();
Source[] schemas = new Source[nrSchemas];
for (int i = 0; i < nrSchemas; ++i)
{
schemas[i] = new DOMSource(schemaNodes.item(i));
}
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemas);
Validator validator = schema.newValidator();
Source soapMessage = new StreamSource(new File("d:\\temp\\soapmessage.xml"));
Result result = new StreamResult(System.out);
validator.validate(soapMessage, result);
I've trimmed the WSDL and only left the relevant parts, or at least what I think is relevant. If more is needed, I'll update the question.
<?xml version='1.0' encoding='UTF-8'?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="run:demo"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="run:demo">
<types>
<xsd:schema targetNamespace="run:demo">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="itemsCT">
<xsd:all>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="Address" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="itemsArray">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="tns:itemsCT[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
</definitions>
The immediate problem is that the schema validator being called is not loading any schema document for namespace http://schemas.xmlsoap.org/soap/encoding/ -- either because it's a generic validator and doesn't have any inbuilt knowledge of SOAP namespaces, or because it did not manage to retrieve the schema document from the server at schemas.xmlsoap.org.
If you have a local copy of the schemas for the http://schemas.xmlsoap.org/soap/encoding/ and http://schemas.xmlsoap.org/wsdl/ namespaces, you might try adding schema location information to the two xsd:import elements in your schema. If you don't have a local copy, then I hope you have better luck getting responses out of schemas.xmlsoap.org than I did just now.