Invalid typenames in WFS:GetFeatures POST? - gis

I'm trying to get even the simplest WFS HTTP_POST request to work, against a GeoServer WFS endpoint.
This HTTP_GET request works, and returns what I expect (newlines inserted for clarity):
http://mygeoserver.com/geoserver/ows?
service=wfs&
version=2.0.0&
request=getfeature&
count=3&
typenames=mynamespace:myfeaturetype&
cql_filter=dccode=%27XYZ%27
I'd expect this HTTP_POST request:
http://mygeoserver.com/geoserver/ows
with this request body:
<GetFeature
version="2.0.0"
service="WFS"
count="3"
xmlns="http://www.opengis.net/wfs/2.0"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd"
>
<Query
typeNames="mynamespace:myfeaturetype"
>
<Filter
xmlns="http://www.opengis.net/fes/2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2" >
<PropertyIsEqualTo>
<ValueReference>dccode</ValueReference>
<Literal>XYZ</Literal>
</PropertyIsEqualTo>
</Filter>
</Query>
</GetFeature>
to return the same.
Instead I get an error:
cvc-datatype-valid.1.2.3: 'mynamespace:myfeaturetype' is not a valid value of union type 'TypeNamesType'.
cvc-attribute.3: The value 'mynamespace:myfeaturetype' of attribute 'typeNames' on element 'Query' is not valid with respect to its type, 'TypeNamesListType'.
What's throwing me for a loop is that the very same value that works for the typeNames parameter in the HTTP_GET throws an error in the HTTP_POST.
The problem seems to be that I need to specify a namespace definition in the XML for "mynamespace".
<Query
typeNames="mynamespace:myfeaturetype"
xmlns:mynamespace="http://????"
>
I'm assuming that this is available, somewhere within my GeoServer installation. But where?

It will be whatever you set as the URI of the workspace mynamespace. You can look it using a describeFeature request. So for example:
curl http://localhost:8080/geoserver/wfs\?service=wfs\&version=1.1.0\&request=DescribeFeatureType\&typeName=topp:states
gives:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:gml="http://www.opengis.net/gml"
xmlns:topp="http://www.openplans.org/topp"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.openplans.org/topp">
<xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
<xsd:complexType name="statesType">
<xsd:complexContent>
[....]

Related

Azure APIM : Convert JSON Response to Customized XML Format

I have a requirement where I want to convert the JSON response , which is an array of object , to the customized XML format , so that my already existing code can parse it.
I know there is a Azure Transformation Policy named <json-to-xml /> , but there is no customization possible with it.
Sample JSON Response:
{
"data":[
{"a":1,"b":2},
{"a":3,"b":4}
],
"param2": "Success",
"param3": "true"
}
Desired XML Format:
<result>
<sub-res>
<res x="a" y=1>
<res x="b" y=2>
</sub-res>
<sub-res>
<res x="a" y=3>
<res x="b" y=4>
</sub-res>
</result>
I have tried using the liquid template as well but no success. Need guidance or pointers on this.
For this requirement, I created an api which response {"data":[{"a":1,"b":2},{"a":3,"b":4}]} to simulate your situation.
Then I use a <json-to-xml> in APIM policy first, the response will be convert to xml shown as below after the <json-to-xml> policy:
<Document>
<data>
<a>1</a>
<b>2</b>
</data>
<data>
<a>3</a>
<b>4</b>
</data>
</Document>
After that, use xslt to convert the xml to which you want.
Below is all of policy in my APIM for your reference:
The result of APIM show as what you want:

How to get response based on the request body matching using wiremock and JSON

How to verify if my Soap request consists of an particular element in header and body using JSON and standalone WireMock.
I should get response1 if my request contain <a:Id>1876</a:Id> in the header else i should get response2
similarly i need to check in body also.
Below is my request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:a="http://abc.example.com/a"
xmlns:b="http://abc.example.com/b"
xmlns:c="http://abc.example.com/c"
<soapenv:Header>
<a:abcHeaders>
<a:Id>1876</a:Id>
<a:Xid>12</a:Xid>
</a:abcHeaders>
</soapenv:Header>
<soapenv:Body>
<b:abcOpern>
<b:xyz>
<c:pqr>12</c:pqr>
</b:xyz>
</b:abcOpern>
</soapenv:Body>
</soapenv:Envelope>
In WireMock.Net you can use XPath matching. For some details see here.

WCF service response from "html" to "xml"

trying to translate from one asmx web service to svc web service. same code, but got the following difference in responce
when using asmx:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.MyKidsSpending.com/">-2202.68</string>
when using svc:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">-2202.68</string>
where did the first line go?
Here is the fist couple of lines of the function that I am testing in the svc service....
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Xml)]
public string Balance(string Uid)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
I was suggested that the response was html, that is why it doesn't have
<?xml version="1.0" encoding="utf-8"?>
now I change text/html to text/xml, why doesn't still match? Suggestions? Thanks

DataWeave transformation issue in esb mule

I have transformation in dataweave.
I am getting input from the Mysql database. Input payload type is List- Map. My dataweave editer has below code.
%dw 1.0
%namespace ns1 urn:abc:api:Components
%output application/xml
---
ns1#"ItemRequest":{
ns1#"Requester":
ns1#ac: payload.time_max,
ns1#"ErrorLanguage": "en_US",
ns1#"WarningLevel": "High"
}
My output is
<?xml version='1.0' encoding='UTF-8'?>
<ns1:ItemRequest xmlns:ns1="urn:abc:api:Components">
<ns1:Requester>
<ns1:ac>
<time_max>1</time_max>
</ns1:ac>
</ns1:Requester>
<ns1:ErrorLanguage>en_US</ns1:ErrorLanguage>
<ns1:WarningLevel>High</ns1:WarningLevel>
</ns1:AddItemRequest>
I am not sure why i am getting tag created under'ac' element in my output with 'time_max'. The 'Time_max' is the column name in MySQL table. But i dont want to add the column in the output xml. How can we avoid this tag creation ?
Expected output is
<?xml version='1.0' encoding='UTF-8'?>
<ns1:ItemRequest xmlns:ns1="urn:abc:api:Components">
<ns1:Requester>
<ns1:ac>1</ns1:ac>
</ns1:Requester>
<ns1:ErrorLanguage>en_US</ns1:ErrorLanguage>
<ns1:WarningLevel>High</ns1:WarningLevel>
</ns1:AddItemRequest>
I have resolved the issue by typing below code.
%dw 1.0
%namespace ns1 urn:abc:api:Components
%output application/xml
---
ns1#"ItemRequest":{
ns1#"Requester":
ns1#ac: payload[0].time_max,
ns1#"ErrorLanguage": "en_US",
ns1#"WarningLevel": "High"
}
The below line of snippet is did magic. I have included array index values.
ns1#ac: payload[0].time_max

Perl module not getting correct web service output

Can someone validate this snippet and point out what I might be doing wrong?
This is my code which creates and does a SOAP call.
my $soap = SOAP::Lite->new()->proxy($proxy)->ns('http://example.com', 'ser')->getInfo(
SOAP::Data->name(chronicId => $ticket_num)->prefix('ser'),
SOAP::Data->name(sourceSystem => $sourceSystem)->prefix('ser'),
SOAP::Data->name(outputFormat => $outputFormat)->prefix('ser'),
SOAP::Data->name(uid => $uid)->prefix('ser'),
SOAP::Data->name(username => $username)->prefix('ser'),
SOAP::Data->name(guid => $guid)->prefix('ser')
);
$results = $soap->call($method);
This is the result I get, when I use a test script to execute the above code.
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getChronicInfoResponse xmlns:ns="http://example.com">
<ns:return xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">
{
"UID":"abc1234",
"GUID":"",
"CHRONICID":123,
"OUTPUTFORMAT":"json",
"USERNAME":"xyz",
"STATUS_SUB_CODE_NAME":"Active",
"SOURCESYSTEM":"abc",
"STATUS_NAME":"Open"
}
</ns:return>
</ns:getChronicInfoResponse>
</soapenv:Body>
</soapenv:Envelope>
However when I try to read the web server response into a variable and print it out, all I get is a 1 (it's not empty though) nothing else. The output is supposed to be in JSON, as shown above, which I would then need to parse.
Any guesses what I might be doing wrong? I am new to Perl so it could be a silly thing.
Sorry I missed the updates. I could use the dumper to see a proper response here, seems like I was receiving a hex value while doing a print on the results which was not right.
The dumper returns a JSON string like -
{
'return' => '{"ATTUID":"pm304a","GUID":"d353f542-43f6-421b-9573-4c9c39ce77e3","CHRONICID":420,"OUTPUTFORMAT":"json","USERNAME":"m91619","STATUS_SUB_CODE_NAME":"Active","SOURCESYSTEM":"Oasis","STATUS_NAME":"Open"}'
};
Now I am trying to parse this json using JSON:XS - decode_json, but end up in an error which says
Malformed JSON string neither array, object, number, string or atom,......
I think thats because of the 'return' in the string, maybe I can strip it out and then pass to decode?