我们使用API Management来公开几个API。我们公开的API之一被配置为SOAP-passthrough API,但我们在APIM身份验证方面遇到了一些问题。
当我们使用subscription-key
标头传递查询字符串时,一切正常,API返回的内容正确。
当我们使用09-14 17:40:33.739 19728-20196/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #6
Process: com.leadtimeapp.io.internal.debug, PID: 19728
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.leadtimeapp.io.internal.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.leadtimeapp.io.internal.debug-2/lib/arm64, /data/app/com.leadtimeapp.io.internal.debug-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libjniavformat.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:586)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.avformat.<clinit>(avformat.java:40)
at com.googlecode.javacv.cpp.avformat.av_register_all(Native Method)
at com.leadtimeapp.io.ffmpeg.NewFFmpegFrameRecorder.<clinit>(NewFFmpegFrameRecorder.java:302)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity.initVideoRecorder(FFmpegRecorderActivity.java:464)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity.access$1400(FFmpegRecorderActivity.java:66)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity$2.doInBackground(FFmpegRecorderActivity.java:368)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity$2.doInBackground(FFmpegRecorderActivity.java:360)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.leadtimeapp.io.internal.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.leadtimeapp.io.internal.debug-2/lib/arm64, /data/app/com.leadtimeapp.io.internal.debug-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libavformat.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
at com.googlecode.javacpp.Loader.load(Loader.java:577)
at com.googlecode.javacpp.Loader.load(Loader.java:540)
at com.googlecode.javacv.cpp.avformat.<clinit>(avformat.java:40)
at com.googlecode.javacv.cpp.avformat.av_register_all(Native Method)
at com.leadtimeapp.io.ffmpeg.NewFFmpegFrameRecorder.<clinit>(NewFFmpegFrameRecorder.java:302)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity.initVideoRecorder(FFmpegRecorderActivity.java:464)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity.access$1400(FFmpegRecorderActivity.java:66)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity$2.doInBackground(FFmpegRecorderActivity.java:368)
at com.leadtimeapp.io.ffmpeg.FFmpegRecorderActivity$2.doInBackground(FFmpegRecorderActivity.java:360)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
09-14 17:40:34.168 19728-19790/? E/NativeCrypto: ssl=0x7f643ae900
cert_verify_callback x509_store_ctx=0x7f76e3e1a0 arg=0x0
09-14 17:40:34.168 19728-19790/? E/NativeCrypto: ssl=0x7f643ae900
cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA
查询字符串参数时,API返回401 Unauthorized。我在Postman中测试了这种行为,并且更改发送订阅密钥的方式导致了这种行为。
此API的实现细节是它公开现有WSDL并通过策略将此SOAPAction路由到Azure功能。在函数的应用程序见解中,我可以验证在获得401时从不调用该函数,但是当我成功调用(使用标题)时调用它。
这是正常行为吗?我做错了吗?或者它是APIM中的错误?
答案 0 :(得分:1)
这可能是我们为SOAP Passthrough进行路由的方式的问题。您将在API设置中注意到我们在查询参数上添加了以识别操作将匹配的SoapAction。将SoapAction参数添加到入站请求时,可能会覆盖api密钥查询参数。我会调查并让你知道。
答案 1 :(得分:0)
我们目前使用以下策略解决此问题。我们发送请求并将该请求的响应设置为此api的响应,而不是更改策略中的后端服务器URL。您可以在下面找到我们在查询字符串中使用订阅密钥的策略。
<policies>
<inbound>
<base />
<send-request mode="copy" response-variable-name="response" timeout="20" ignore-error="false">
<set-url>{{BackendServer_URL}}</set-url>
</send-request>
<!--return-response response-variable-name="reponse" /-->
<choose>
<!-- If StatusCode is not OK, return Unauthorized with the reason. -->
<when condition="@(((IResponse)context.Variables["response"]).StatusCode != 200)">
<return-response response-variable-name="reponse">
<set-status code="401" reason="Unauthorized" />
<set-body>@(((IResponse)context.Variables["response"]).Body.As<string>())</set-body>
</return-response>
</when>
<otherwise>
<return-response response-variable-name="reponse">
<set-status code="200" />
<set-header name="Content-Type" exists-action="override">
<value>text/xml; charset=utf-8</value>
</set-header>
<set-body>@(((IResponse)context.Variables["response"]).Body.As<string>())</set-body>
</return-response>
</otherwise>
</choose>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>