I need to connect to a web service without knowing the wsdl; the only info I have is a sample request like the one below but I have no idea where to start from to build this xml; for example what is wsse:BinarySecurityToken? and do I have to create also prefixes like "wsu" or "wsse" ???
The info below are from a test server so there are any sensitive data disclosed here.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="Username-123" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>gen-emiswebmobile.e-mis.co.uk</wsse:Username> </wsse:UsernameToken> <wsu:Timestamp wsu:Id="Timestamp-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsu:Created>2017-06-29T22:42:44.870Z</wsu:Created> <wsu:Expires>2017-06-29T22:57:44.870Z</wsu:Expires> </wsu:Timestamp> <wsse:BinarySecurityToken wsu:Id="CertId-4468839874371617328" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">MIIFVjCCBD6gAwIBAgIHTvS0LmWypjANBgkqhkiG9w0BAQsFADCBtDELMAkGA1UEBhMCVVMxEDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMuMS0wKwYDVQQLEyRodHRwOi8vY2VydHMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeS8xMzAxBgNVBAMTKkdvIERhZGR5IFNlY3VyZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjAeFw0xNDEwMDgwNzMzNDdaFw0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IXd3dy5nZW4tZW1pc3dlYm1vYmlsZS5lLW1pcy5jby51azAdBgNVHQ4EFgQUfnm7SRUsh4sUkMHC41QY+Q3ysZ0wDQYJKoZIhvcNAQELBQADggEBAK3zIhwhU3N7bxGjRVTFsQDLvJBjrIeJiRHXTtPF8A/muYJdcapUTcz/cl8mu9hXN3po0WJQii2kttBQD7MAjHlIMDDY6iTDrEorqch0OUSc6tJe6KQlNdeE4Cng11/AlcTBNitxE8aNiC8PUsh4P4Se8jDNoa7ESSgv9MXpHUT+Dfx5wsM4CPkUMhdaQiPQPL4QzbwpphX+hD4DTGGkKR34HR91HLoUap/gOS97ZTUmUBtgOSSKGL+kVrs+HKA6+Zbv55ya0bYFHJikN/5R1XUgZX6l3VZJJvBnmFHETd2I6H/1/VKOiSoD4JNZf7cxfDRmi8cLixE6PdSM41ve6qw=</wsse:BinarySecurityToken> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /> <Reference URI="#Timestamp-1"> <Transforms> <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" /> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <DigestValue>WOHqa2p3/ZcVQ2FU36OEU9gfYaI=</DigestValue> </Reference> </SignedInfo> <SignatureValue>q/ZGfYAacr6Vv/LwfyAwyxXGLVkJ7qXJYkMvrCludwNRaENHNR1LekPwVuMGQ95uoKzk9npEnefHrCD1+JmufKltDtXLIZmhUJNryhOcUHzSoDLjdCAOJ+Ylccf73fhI7uHJr63NlbmV6IVzTrb3RPpfoJDpuDqyrkqS0l4HQI3BkzbDYR3Eo3ce8oUzfZ32xpLTQ/LceI6DsaHMCtimxjhAJDa1NuRDbsosHgxw8MEms1hc5VwR4s2/h6GJEkz5EXegWkm9CBNlpgceaFF7HMUPZqm7PUTHTrsmfN9uEZlp4iaUQrCBPNwsju3dbD1nOxNAxQeGvx5RNL0xvY5emg==</SignatureValue> <KeyInfo Id="KeyId-4468839874371617327"> <wsse:SecurityTokenReference wsu:Id="STRId-3E04823056058230" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#CertId-4468839874371617328" /> </wsse:SecurityTokenReference> </KeyInfo> </Signature> </wsse:Security> <Action xmlns="http://www.w3.org/2005/08/addressing">MiG</Action> <MessageID xmlns="http://www.w3.org/2005/08/addressing">84CF41DA-133A-442D-979B-D76697AF71BF</MessageID> <To xmlns="http://www.w3.org/2005/08/addressing">https://185.13.72.96/Miggateway</To> <ReplyTo xmlns="http://www.w3.org/2005/08/addressing"> <Address>http://www.w3.org/2005/08/addressing/anonymous</Address> </ReplyTo> </soap:Header> <soap:Body> <q1:migRequest xmlns:q1="http://www.healthcaregateway.co.uk/mig"> <q1:serviceDefinition> <q1:name>MIG.DATAEXTRACTIONSERVICE.EhrExtractRequest</q1:name> <q1:version>0.0.2</q1:version> </q1:serviceDefinition> <q1:serviceHeader> <q1:source xmlns:q1="http://www.healthcaregateway.co.uk/mig"> <q1:identifier>externaldevuser:urn:hgl:addressing:ods:N00001</q1:identifier> </q1:source> <q1:target xmlns:q1="http://www.healthcaregateway.co.uk/mig"> <q1:nationalCode>urn:hgl:addressing:ods:A00005</q1:nationalCode> </q1:target> </q1:serviceHeader> <q1:serviceContent> <q1:ehrExtractRequestv2-0 xmlns:q1="http://www.healthcaregateway.co.uk/mig"> <q1:id>4df5cdb1-4a20-42a5-b604-6033eec5224d</q1:id> <q1:consent> <q1:value>Given</q1:value> </q1:consent> <q1:provenance> <q1:creationTime>2013-07-15T14:37:28.7273043Z</q1:creationTime> <q1:system> <q1:id>BED045C0-BC58-4934-8E11-2FC08F730060</q1:id> <q1:name>EMISWebCR1 50002</q1:name> </q1:system> </q1:provenance> <q1:patient> <q1:primaryIdentifier type="NHS">8888888888</q1:primaryIdentifier> </q1:patient> <q1:requestSpecification> <q1:id>654d8e02-6b09-4754-a095-968c397db560</q1:id> <q1:responseFormat>OPENHR</q1:responseFormat> <q1:request> <q1:name>scm.diagnosis</q1:name> <q1:includeAssociatedText>true</q1:includeAssociatedText> </q1:request> </q1:requestSpecification> </q1:ehrExtractRequestv2-0> </q1:serviceContent> </q1:migRequest> </soap:Body>
2 Answers
Answers 1
You can look here for some code sample.
The xml you posted is the soap envelope xml and you should be able to send it as shown in the sample (with LoadXml) and get a response. (in the xml you posted you invoke the MiG action with migRequest).
If you dont have the soap envelope request you will have to create one and it is the tricky part if you dont know which functions to call.
The structure of the request is this: (in your sample there is also security which is not present here)
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <MethodFoo> <param1>value</param1> <param2>value</param1> </MethodFoo> </soap:Body> </soap:Envelope>
Look here for more on the request message structure.
Answers 2
There are few ways to connect to a web service. Basically, you use one of the class to "post" the exact xml to the URL.
The common ways are to use WebClient, HttpClient. It is a relatively simple to post an xml to an URL.
If I understand you correctly, you are looking at ways of how to construct the Xml in the exact format required.
One way, we have handled a similar request is by the following approach.
Take the sample xml and convert it to a template
for eg,
<q1:system> <q1:id>BED045C0-BC58-4934-8E11-2FC08F730060</q1:id> <q1:name>EMISWebCR1 50002</q1:name> </q1:system>
becomes
<q1:system> <q1:id>~system_id~</q1:id> <q1:name>~system_name~</q1:name> </q1:system>
In the above sample ~system_id~
, ~system_name~
are the placeholders. In your application code you do a find and replace with the actual values.
This does look like "low key"... but in the good old days (i.e., before we have xml everywhere), this was a popular approach :-)
Another more Xml way is to construct a C# class in the exact format. You populate your object with relevant values. Then you serialize your C# class to xml and post it to the URL. There are some popular SO links for this: Generate C# class from XML
0 comments:
Post a Comment