Is it possible to require min and max string length for param in wsdl file? - soap

I am creating a web service using php SOAPServer. I am creating a wsdl file and looking for info on how to set the min and max string length for one of the input parameters for one of the web service operations. Is it even possible?
By the way I am using soap binding style "rpc"

Do you code the WSDL by hand or does the library create it for you by looking at an endpoint class? If you are coding the WSDL by hand, you could simply add something like this in your schema descriptor:
<simpleType name="MyStringType">
<restriction base="string">
<minLength value="10" />
<maxLength value="30" />
</restriction>
</simpleType>
<element name="greetMe">
<complexType>
<sequence>
<element name="requestType"
type="tns:MyStringType"/>
</sequence>
</complexType>
</element>

Its probably because the service's validation is turned off. Check your framework and see if there is a flag that needs to be set in one of the xml's (application-context.xml) for the service config.

Related

Azure Service Fabric - Configure service instance parameters using Powershell

Is it possible to inject parameters at run time into a Guest Executable via the Settings.xml file or another means? I have a GuestExecutable which I need to pass some configuration to it - a URL at service creation time.
I need two instances of the service running with different parameters, the service instance information has to differ in terms of a custom parameter I need to pass through . Is this possible using Powershell or, do I need to version the config and create a new version?
Thanks in advance
Have you tried the following command: New-ServiceFabricApplication ?
When you create your application manifest file, the parameters will contain replaceable parameters that you set when you register a new application.
An ApplicationManifest.xml example like this:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="MyAppTypeName" ApplicationTypeVersion="1.0.0" xmlns=...>
<Parameters>
<Parameter Name="Web1_InstanceCount" Value="-1" />
<Parameter Name="ENVIRONMENT_NAME" Value="DEV" />
<Parameter Name="FEPlacementConstraints" Value="NodeTypeName==FrontEnd" />
</Parameters>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="MyServicePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<EnvironmentOverrides />
</ServiceManifestImport>
<DefaultServices>
<Service Name="Web1">
<StatelessService ServiceTypeName="MyServiceType" InstanceCount="[Web1_InstanceCount]">
<SingletonPartition />
<PlacementConstraints>[FEPlacementConstraints]</PlacementConstraints>
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
You would change the settings file using config overrides like this:
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
<Section Name="MyConfigSection">
<Parameter Name="MySetting" Value="[ENVIRONMENT_NAME]"/>
</Section>
</Settings>
</ConfigOverride>
</ConfigOverrides>
Or you could set environment variables on your service like this:
<EnvironmentOverrides CodePackageRef="Code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ENVIRONMENT_NAME]" />
</EnvironmentOverrides>
In my opinion the environment overrides would work better on your case,
because most guest executable are not flexible on how you can configure them but generally they accept environment variables.
Then you:
Upload your application with: Copy-ServiceFabricApplicationPackage
Register your application with Register-ServiceFabricApplicationType
And then you register each new app with the settings you need:
.
New-ServiceFabricApplication -ApplicationName fabric:/myapp/todolist-dev -ApplicationTypeName "MyAppTypeName" -ApplicationTypeVersion "1.0.0" -ApplicationParameter #{Web1_InstanceCount='-1'; ENVIRONMENT_NAME='DEV'}
New-ServiceFabricApplication -ApplicationName fabric:/myapp/todolist-uat -ApplicationTypeName "MyAppTypeName" -ApplicationTypeVersion "1.0.0" -ApplicationParameter #{Web1_InstanceCount='-1'; ENVIRONMENT_NAME='UAT'}
The only down side of this approach is that you would end up with two applications, but don't think would be a problem for you, they will be managed mostly the same way as you would do with a single application.
if you strictly need to run both together on same application, you could do some workarounds:
Using multiple Config packages(don't think would work well with guest executables, but works well with reliable services
Using the startup script, where you would add the logic to pass the parameter to your startup exe, something like the following:
In your ServiceManifest.xml:
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>start.bat</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
On the same folder (code) of your .exe, you create the start.bat file with following contents:
myApp.exe %EnvironmentVariableNameSetBySF%

Service Fabric Multiple service instances with config override

Our service fabric application includes a stateless service that exposes an HTTP endpoint through OwinCommunicationListener.
The ServiceManifest.Xml for this service specifies the service endpoint <Endpoint Name="ServiceEndpoint" Type="Input" Protocol="http" Port="8090" />
The stateless service can then be accessed via a browser on http://localhost:8090/
What we are trying to do is instantiate multiple instances of this service on different endpoints in the same Service Fabric application through the ApplicationManifest.
The ServiceManifestImport imports our service package and allows configuration overrides at the application level. We're not able to override the ServiceEndpoint this way, only the values in Settings.xml
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="FooServicePkg" ServiceManifestVersion="1.0.0" >
<ConfigOverrides Name="Config">
<Settings>
<SectionName Name="MySettings">
<Parameter Name="MySetting" Value="SomeValue">
</Settings>
</ConfigOverrides>
</ServiceManifestImport>
We can create named instances of the service by specifying multiple Service nodes under DefaultServices
<DefaultServices>
<Service Name="FooInstanceA">
<StatelessService ServiceTypeName="FooType" InstanceCount="1" />
<SingletonPartition />
</StatelessService>
</Service>
<Service Name="FooInstanceB">
<StatelessService ServiceTypeName="FooType" InstanceCount="1" />
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
Is it possible to specify configuration overrides per instance of a service through configuration?
I tried to make the service instances listen on a specific port by using their service name to work out which port so FooInstanceA listens on port 8090 and FooInstanceB listens on 8091.
Clearly Service Fabric is doing some magic during deployment because when FooInstanceB listens on a port other than the one specified on the ServiceEndpoint configuration the service is not accessible.
The first reason is the DACL is not set on the endpoint, this is resolved by running;
netsh http add urlacl http://+:8091/ user=everyone listen=yes
This allows the services to come up and show healthy in the Service Fabric Explorer, however the FooInstanceB is responding with an HTTP 503 error when we access with http://localhost:8091/
How can we get the service instances listening on different ports?
I hope that's clear, thank you.
Not a lot of great options to accomplish this. Here are some ideas:
Create multiple application instances instead of multiple services of the same type within an app. That would allow you to use the app parameters to configure the behavior of the particular service.
Create multiple config packages within your service type. Each config package would be intended for one of the service instances. Determining which config package a service instance is assigned to would need to be dynamic, maybe based on the service instance's name? Not a great option, of course, since it couples the service definition with the number of instances that will be created.
A custom configuration implementation. Maybe have your service expose an endpoint that allows you to configure it post-deployment. Or have the service call some other management service that provides its configuration at activation time.
You can also let Service Fabric assign the ports automatically and then use the reverse proxy that comes with Service Fabric.
I think its a very good idea to have a url rewriting service in front of a SF cluster .
This can give you multiple end points and do url rewriting , firewalls/ black listing , https etc .
Other way is to package the service as a lib or in Nuget and create the N services you need with different service manifests.
I've managed to do this using ApplicationParameter xml files and choose the right one during deployment in VSTS.
This, for example, is my Cloud.xml which I use for deployment to my test environment. The trick is the Name parameter on the second line. I've specified the port using this documentation: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-how-to-specify-port-number-using-parameters
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/DotNetCoreTest" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Web1_InstanceCount" Value="2" />
<Parameter Name="ServiceEndpoint_PortNumber" Value="8909" />
</Parameters>
</Application>
This is the xml file for Staging: Staging.xml
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/DotNetCoreStaging" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Web1_InstanceCount" Value="2" />
<Parameter Name="ServiceEndpoint_PortNumber" Value="8910" />
</Parameters>
</Application>
Using the Traefik Reverse Proxy as described here I can use a hostname to reach my service.
In VSTS I'm using a tokenizer to replace both the host name in the ServiceManifest and replacing the ApplicationTypeName in the ApplicationManifest during deployment.
This is my ServiceManifest:
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="Web1Type">
<Extensions>
<Extension Name="Traefik">
<Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
<Label Key="traefik.frontend.rule.hostname">Host: #{HostName}#</Label>
<Label Key="traefik.expose">true</Label>
<Label Key="traefik.frontend.passHostHeader">true</Label>
</Labels>
</Extension>
</Extensions>
</StatelessServiceType>
</ServiceTypes>

Add User and Pass to SOAP Header in Mule

It seems this should be simple but the solution has been eluding me. My flow is XML -> XSLT translation -> consume web service (IBM Web Sphere Web Service to be specific). I have the pieces working individually but I am having trouble figuring out how to add user/pass to the SOAP header. I would think that I should be able to add them to the keys in the security tab on the Mule SOAP Component (I have the operation set to Proxy Client). Unfortunately, I cannot figure out what the valid keys are. Maybe I am way off base even attempting to use the security tab. So ultimately I need my outgoing XML to contain:
<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">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>
myUserName
</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
myPa33W0rd
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
Currently my Mule flow is putting out:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
Do I need to add the security information manually (maybe in the XSLT translation)? That doesn't feel right but I can't figure out how to add it.
Here are the relevant lines from my flow:
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="src\main\resources\MappingMapToChangeCatalogEntry.xslt" outputEncoding="US-ASCII" doc:name="XSLT"/>
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
In order to add WS-Sec you need to configure the CXF WSS4J interceptors and inject them into Mule's CXF message processors.
Pre 3.3 =
<spring:bean name="wss4jOutConfiguration"
class="org.springframework.beans.factory.config.MapFactoryBean">
<spring:property name="sourceMap">
<spring:map>
<spring:entry key="action" value="Signature" />
<spring:entry key="user" value="joe" />
<spring:entry key="signaturePropFile" value="org/mule/module/cxf/wssec/wssecurity.properties" />
<spring:entry key="passwordCallbackClass" value="org.mule.module.cxf.wssec.ClientPasswordCallback" />
</spring:map>
</spring:property>
</spring:bean>
...
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP">
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<spring:property name="properties" ref="wss4jOutConfiguration"/>
</spring:bean>
</cxf:outInterceptors>
</cxf:proxy-client>
Rough Sample Password Callback class:
public class ClientPasswordCallback implements CallbackHandler{
#Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
WSPasswordCallback callback = (WSPasswordCallback) callbacks[0];
if(callback.getIdentifier().equals("joe")){
callback.setPassword("pass");
}
}
See more here: http://www.mulesoft.org/documentation/display/current/WS-Security+Usability+Improvement
3.3.+ :
There is a new cxf:ws-security element availble in 3.3+ Here is an example flow here: https://svn.codehaus.org/mule/tags/mule-3.4-M2/modules/cxf/src/test/resources/org/mule/module/cxf/wssec/cxf-secure-proxy-flow.xml
<cxf:proxy-client payload="body"
enableMuleSoapHeaders="true" doc:name="SOAP">
<cxf:ws-security>
<cxf:ws-config>
<cxf:property key="action"
value="UsernameToken
Timestamp" />
<cxf:property key="user" value="joe" />
<cxf:property key="passwordCallbackClass"
value="com.mulesoft.mule.example.security.PasswordCallback" />
<cxf:property key="mustUnderstand" value="false" />
</cxf:ws-config>
</cxf:ws-security>
</cxf:proxy-client>
Previously I have also just handled he entire envelope myself when using XSLT. I have then passed the user and pass into the XSLT via context params
<xm:xslt-transformer xsl-file="xslt/ToSomethingSOAPY.xsl">
<xm:context-property key="user" value="${my.user}" />
<xm:context-property key="password" value="${my.pass}" />
</xm:xslt-transformer>
And then reieived them via xsl params like so:
<xsl:param name="user" />
....
<wsse:UsernameToken
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="UsernameToken-1018444980">
<wsse:Username><xsl:value-of select="$user" /></wsse:Username>

How to schedule a report with collection type parameter via REST API in JasperReports Server?

I'm using JasperReports Server v4.5.
We are having difficulties with scheduling a report by using REST API.
We are able to schedule a report that only accepts string parameters however the problem begins with a report that has a java.util.Collection type parameter. We tried everything but couldn't find the correct type for java.util.Collection.
Right now this works:
<parameters>
<name>string_input</name>
<value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
test
</value>
</parameters>
But we couldn't get this working:
<parameters>
<name>array_parameter</name>
<value type=? >[1, 2, 3]</value>
</parameters>
When I looked into the code, I can see that JasperReports Server WS accepts arrays, however there is no documented way to send the arrays or array types.
What is the correct way to solve this issue?
Give this a try:
<parameters>
<entry>
<key>param_name</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="collection">
<item xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">1</item>
<item xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</item>
</value>
</entry>
</parameters>
Update:
Some have suggested removing the entry tags. If the above does not work, try removing the entry tags.

odatagen: Failed to generate proxy classes. Please verify the metadata (iOS)

Im working on Open Data Protocol (OData) which is a standardized protocol for creating and consuming data API's.
OData builds on core protocols like HTTP and commonly accepted methodologies like REST .
I have installed, configured and built OData successfully on iOS6
Currently I'm creating a Proxy class to connect to the OData Service using the following commands:
cd /Users/Shamsu/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug
./odatagen /uri=http://35.35.6.4/MyApp.MyApp3D.DataService/MyApp3DDataService.svc/ /out=/Users/Ramshad/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /u=sa /p=123
However, I'm getting the error: "odatagen: Failed to generate proxy classes. Please verify the metadata"
I can see the "metadata.xml" file is updated as
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="MyAppDBModel" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="User">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="Edm.Guid" Nullable="false" />
<Property Name="UserName" Type="Edm.String" MaxLength="10" FixedLength="true" Unicode="true" />
<Property Name="UserDescription" Type="Edm.String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Active" Type="Edm.Int64" />
</EntityType>
</Schema>
<Schema Namespace="MyApp.MyApp3D.DataService" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="MyAppDBEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="User" EntityType="MyAppDBModel.User" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx> "
Note: the metadata.xml file is located at out param location (/Users/Ramshad/Applications/ODataObjC/ODataSDKV11.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /metadata.xml)
I'm unable to identify the issue. Any problem with my windows WCF service /ODataService configuration/database configuration ? Permission assigned as * (read,write).
Any help on this issue is appreciated.
Thanks.
I looked a bit closer at the XSLT document I linked to in my original comment, and it seems that the odatagen tool hasn't been updated to work with CSDL v3. The version of CSDL (i.e., the format used to serialize the metadata document) is indicated by the xml namespace of the Schema element. In your metadata, that namespace is http://schemas.microsoft.com/ado/2009/11/edm, which indicates CSDL v3. You can see in the XSLT document here that this namespace isn't recognized by the odatagen tool.
Since the odatagen tool is open source (see the source on github), you can try to tweak the code and XSLT files to make it work for your situation. You could try to just add the v3 namespace to the recognized schema namespaces, and if your metadata doesn't use any v3 features, I would imagine it would just work. Off the top of my head I'm not sure of the exact differences between v2 and v3, so I can't immediately say whether the metadata you've posted above would be valid in CSDL v2.
Alternatively, you could try to generate the $metadata document so that it's using CSDL v2 instead.
Sorry I don't have a better answer for you. Unfortunately, the odatagen tool has fallen a bit behind. But you're more than welcome to contribute to the project :)